Support zone expanders in alarmdecoder (#27167)

This commit is contained in:
Hugh Eaves 2019-10-03 21:01:06 -04:00 committed by Paulus Schoutsen
parent c6b08b28b2
commit d36d123cf7
2 changed files with 9 additions and 4 deletions

View file

@ -174,7 +174,7 @@ def setup(hass, config):
hass.helpers.dispatcher.dispatcher_send(SIGNAL_ZONE_RESTORE, zone)
def handle_rel_message(sender, message):
"""Handle relay message from AlarmDecoder."""
"""Handle relay or zone expander message from AlarmDecoder."""
hass.helpers.dispatcher.dispatcher_send(SIGNAL_REL_MESSAGE, message)
controller = False
@ -195,7 +195,7 @@ def setup(hass, config):
controller.on_zone_fault += zone_fault_callback
controller.on_zone_restore += zone_restore_callback
controller.on_close += handle_closed_connection
controller.on_relay_changed += handle_rel_message
controller.on_expander_message += handle_rel_message
hass.data[DATA_AD] = controller

View file

@ -151,10 +151,15 @@ class AlarmDecoderBinarySensor(BinarySensorDevice):
self.schedule_update_ha_state()
def _rel_message_callback(self, message):
"""Update relay state."""
"""Update relay / expander state."""
if self._relay_addr == message.address and self._relay_chan == message.channel:
_LOGGER.debug(
"Relay %d:%d value:%d", message.address, message.channel, message.value
"%s %d:%d value:%d",
"Relay" if message.type == message.RELAY else "ZoneExpander",
message.address,
message.channel,
message.value,
)
self._state = message.value
self.schedule_update_ha_state()