Refactor mysensors message handling (#17214)

* Refactor mysensors message handling

* Add handler module and register handlers per message type or message
  sub-type. This will allow easier extension of message handling in the
  future.
* Move some common functions to a helpers module.

* Add node handler and signal

* Fix inconsistent return

* Upgrade pymysensors to 0.18.0

* Fix bug in message modification.
This commit is contained in:
Martin Hjelmare authored and GitHub committed 2018-11-04 21:08:27 +01:00
1 parent 4a7507bcea
commit 9a6c229b1d
8 files changed
+216 -130

No files matched your search

@@ -19,11 +19,16 @@ async def async_setup_scanner(hass, config, async_see, discovery_info=None):
return False
for device in new_devices:
gateway_id = id(device.gateway)
dev_id = (
id(device.gateway), device.node_id, device.child_id,
gateway_id, device.node_id, device.child_id,
device.value_type)
async_dispatcher_connect(
hass, mysensors.const.SIGNAL_CALLBACK.format(*dev_id),
hass, mysensors.const.CHILD_CALLBACK.format(*dev_id),
device.async_update_callback)
async_dispatcher_connect(
hass,
mysensors.const.NODE_CALLBACK.format(gateway_id, device.node_id),
device.async_update_callback)
return True