1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Add MySensors ACK (#26894)

* Add MySensors ACK

The addition of the ACK will ask sensors to respond to commands sent to them which will update the MySensors device in Home Assistant.
 Currently, if a default MySensors sketch is used the device will update but Home Assistant does not reflect the update and custom code has to be added to tell Home Assistant the command was received.  With the ACK set to 1 in the message all this is taken care of by MySensors.

* Run black
This commit is contained in:
petewill
2019-09-25 15:20:02 -06:00
committed by Martin Hjelmare
parent b75639d9d1
commit d1b4bd22ce
4 changed files with 37 additions and 15 deletions

View File

@@ -75,7 +75,9 @@ class MySensorsLight(mysensors.device.MySensorsEntity, Light):
if self._state:
return
self.gateway.set_child_value(self.node_id, self.child_id, set_req.V_LIGHT, 1)
self.gateway.set_child_value(
self.node_id, self.child_id, set_req.V_LIGHT, 1, ack=1
)
if self.gateway.optimistic:
# optimistically assume that light has changed state
@@ -96,7 +98,7 @@ class MySensorsLight(mysensors.device.MySensorsEntity, Light):
brightness = kwargs[ATTR_BRIGHTNESS]
percent = round(100 * brightness / 255)
self.gateway.set_child_value(
self.node_id, self.child_id, set_req.V_DIMMER, percent
self.node_id, self.child_id, set_req.V_DIMMER, percent, ack=1
)
if self.gateway.optimistic:
@@ -129,7 +131,7 @@ class MySensorsLight(mysensors.device.MySensorsEntity, Light):
if len(rgb) > 3:
white = rgb.pop()
self.gateway.set_child_value(
self.node_id, self.child_id, self.value_type, hex_color
self.node_id, self.child_id, self.value_type, hex_color, ack=1
)
if self.gateway.optimistic:
@@ -141,7 +143,7 @@ class MySensorsLight(mysensors.device.MySensorsEntity, Light):
async def async_turn_off(self, **kwargs):
"""Turn the device off."""
value_type = self.gateway.const.SetReq.V_LIGHT
self.gateway.set_child_value(self.node_id, self.child_id, value_type, 0)
self.gateway.set_child_value(self.node_id, self.child_id, value_type, 0, ack=1)
if self.gateway.optimistic:
# optimistically assume that light has changed state
self._state = False