1 """Support for Bond covers."""
3 from __future__
import annotations
7 from bond_async
import Action, DeviceType
18 from .
import BondConfigEntry
19 from .entity
import BondEntity
20 from .models
import BondData
21 from .utils
import BondDevice
25 """Convert bond 0-open 100-closed to hass 0-closed 100-open."""
26 return abs(bond_position - 100)
30 """Convert hass 0-closed 100-open to bond 0-open 100-closed."""
31 return 100 - hass_position
36 entry: BondConfigEntry,
37 async_add_entities: AddEntitiesCallback,
39 """Set up Bond cover devices."""
40 data = entry.runtime_data
43 for device
in data.hub.devices
44 if device.type == DeviceType.MOTORIZED_SHADES
49 """Representation of a Bond cover."""
51 _attr_device_class = CoverDeviceClass.SHADE
53 def __init__(self, data: BondData, device: BondDevice) ->
None:
54 """Create HA entity representing Bond cover."""
57 if self.
_device_device.supports_set_position():
58 supported_features |= CoverEntityFeature.SET_POSITION
59 if self.
_device_device.supports_open():
60 supported_features |= CoverEntityFeature.OPEN
61 if self.
_device_device.supports_close():
62 supported_features |= CoverEntityFeature.CLOSE
63 if self.
_device_device.supports_tilt_open():
64 supported_features |= CoverEntityFeature.OPEN_TILT
65 if self.
_device_device.supports_tilt_close():
66 supported_features |= CoverEntityFeature.CLOSE_TILT
67 if self.
_device_device.supports_hold():
68 if self.
_device_device.supports_open()
or self.
_device_device.supports_close():
69 supported_features |= CoverEntityFeature.STOP
70 if self.
_device_device.supports_tilt_open()
or self.
_device_device.supports_tilt_close():
71 supported_features |= CoverEntityFeature.STOP_TILT
75 state = self.
_device_device.state
76 cover_open = state.get(
"open")
77 self.
_attr_is_closed_attr_is_closed =
None if cover_open
is None else cover_open == 0
78 if (bond_position := state.get(
"position"))
is not None:
82 """Set the cover position."""
83 await self.
_bond_bond.action(
101 """Open the cover tilt."""
102 await self.
_bond_bond.action(self.
_device_id_device_id, Action.tilt_open())
105 """Close the cover tilt."""
106 await self.
_bond_bond.action(self.
_device_id_device_id, Action.tilt_close())
109 """Stop the cover."""
None async_set_cover_position(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None __init__(self, BondData data, BondDevice device)
_attr_current_cover_position
None async_stop_cover_tilt(self, **Any kwargs)
None async_stop_cover(self, **Any kwargs)
None async_open_cover_tilt(self, **Any kwargs)
None async_close_cover(self, **Any kwargs)
None async_close_cover_tilt(self, **Any kwargs)
int _bond_to_hass_position(int bond_position)
int _hass_to_bond_position(int hass_position)
None async_setup_entry(HomeAssistant hass, BondConfigEntry entry, AddEntitiesCallback async_add_entities)