1 """Support for MySensors covers."""
3 from __future__
import annotations
5 from enum
import Enum, unique
15 from .
import setup_mysensors_platform
16 from .const
import MYSENSORS_DISCOVERY, DiscoveryInfo
17 from .entity
import MySensorsChildEntity
18 from .helpers
import on_unload
23 """An enumeration of the standard cover states."""
33 config_entry: ConfigEntry,
34 async_add_entities: AddEntitiesCallback,
36 """Set up this platform for a specific ConfigEntry(==Gateway)."""
39 """Discover and add a MySensors cover."""
45 async_add_entities=async_add_entities,
50 config_entry.entry_id,
53 MYSENSORS_DISCOVERY.format(config_entry.entry_id, Platform.COVER),
60 """Representation of the value of a MySensors Cover child node."""
63 """Return a CoverState enum representing the state of the cover."""
64 set_req = self.gateway.const.SetReq
65 v_up = self._values.
get(set_req.V_UP) == STATE_ON
66 v_down = self._values.
get(set_req.V_DOWN) == STATE_ON
67 v_stop = self._values.
get(set_req.V_STOP) == STATE_ON
73 if set_req.V_DIMMER
in self._values:
74 amount = self._values[set_req.V_DIMMER]
76 amount = 100
if self._values.
get(set_req.V_LIGHT) == STATE_ON
else 0
79 return CoverState.CLOSED
80 if v_up
and not v_down
and not v_stop:
81 return CoverState.OPENING
82 if not v_up
and v_down
and not v_stop:
83 return CoverState.CLOSING
84 return CoverState.OPEN
88 """Return True if the cover is closed."""
93 """Return True if the cover is closing."""
98 """Return True if the cover is opening."""
103 """Return current position of cover.
105 None is unknown, 0 is closed, 100 is fully open.
107 set_req = self.gateway.const.SetReq
108 return self._values.
get(set_req.V_DIMMER)
111 """Move the cover up."""
112 set_req = self.gateway.const.SetReq
113 self.gateway.set_child_value(
114 self.node_id, self.child_id, set_req.V_UP, 1, ack=1
118 if set_req.V_DIMMER
in self._values:
119 self._values[set_req.V_DIMMER] = 100
121 self._values[set_req.V_LIGHT] = STATE_ON
125 """Move the cover down."""
126 set_req = self.gateway.const.SetReq
127 self.gateway.set_child_value(
128 self.node_id, self.child_id, set_req.V_DOWN, 1, ack=1
132 if set_req.V_DIMMER
in self._values:
133 self._values[set_req.V_DIMMER] = 0
135 self._values[set_req.V_LIGHT] = STATE_OFF
139 """Move the cover to a specific position."""
140 position = kwargs.get(ATTR_POSITION)
141 set_req = self.gateway.const.SetReq
142 self.gateway.set_child_value(
143 self.node_id, self.child_id, set_req.V_DIMMER, position, ack=1
147 self._values[set_req.V_DIMMER] = position
151 """Stop the device."""
152 set_req = self.gateway.const.SetReq
153 self.gateway.set_child_value(
154 self.node_id, self.child_id, set_req.V_STOP, 1, ack=1
None async_set_cover_position(self, **Any kwargs)
None async_stop_cover(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None async_close_cover(self, **Any kwargs)
CoverState get_cover_state(self)
None async_write_ha_state(self)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
None on_unload(HomeAssistant hass, GatewayId gateway_id, Callable fnct)
None async_discover(DiscoveryInfo discovery_info)
list[MySensorsChildEntity]|None setup_mysensors_platform(HomeAssistant hass, Platform domain, DiscoveryInfo discovery_info, type[MySensorsChildEntity]|Mapping[SensorType, type[MySensorsChildEntity]] device_class,(tuple|None) device_args=None, Callable|None async_add_entities=None)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)