mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
6f1f8ffea0
@ -143,28 +143,24 @@ def pf_callback_factory(
|
|||||||
if gateway.sensors[node_id].sketch_name is None:
|
if gateway.sensors[node_id].sketch_name is None:
|
||||||
_LOGGER.info('No sketch_name: node %s', node_id)
|
_LOGGER.info('No sketch_name: node %s', node_id)
|
||||||
return
|
return
|
||||||
# previously discovered, just update state with latest info
|
|
||||||
if node_id in devices:
|
|
||||||
for entity in devices[node_id]:
|
|
||||||
entity.update_ha_state(True)
|
|
||||||
return
|
|
||||||
|
|
||||||
# First time we see this node, detect sensors
|
|
||||||
for child in gateway.sensors[node_id].children.values():
|
for child in gateway.sensors[node_id].children.values():
|
||||||
name = '{} {}.{}'.format(
|
|
||||||
gateway.sensors[node_id].sketch_name, node_id, child.id)
|
|
||||||
|
|
||||||
for value_type in child.values.keys():
|
for value_type in child.values.keys():
|
||||||
|
key = node_id, child.id, value_type
|
||||||
if child.type not in s_types or value_type not in v_types:
|
if child.type not in s_types or value_type not in v_types:
|
||||||
continue
|
continue
|
||||||
|
if key in devices:
|
||||||
|
devices[key].update_ha_state(True)
|
||||||
|
continue
|
||||||
|
name = '{} {}.{}'.format(
|
||||||
|
gateway.sensors[node_id].sketch_name, node_id, child.id)
|
||||||
|
devices[key] = entity_class(
|
||||||
|
gateway, node_id, child.id, name, value_type)
|
||||||
|
|
||||||
devices[node_id].append(
|
_LOGGER.info('Adding new devices: %s', devices[key])
|
||||||
entity_class(gateway, node_id, child.id, name, value_type))
|
add_devices([devices[key]])
|
||||||
if devices[node_id]:
|
if key in devices:
|
||||||
_LOGGER.info('adding new devices: %s', devices[node_id])
|
devices[key].update_ha_state(True)
|
||||||
add_devices(devices[node_id])
|
|
||||||
for entity in devices[node_id]:
|
|
||||||
entity.update_ha_state(True)
|
|
||||||
return mysensors_callback
|
return mysensors_callback
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/sensor.mysensors/
|
https://home-assistant.io/components/sensor.mysensors/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
v_types = [member for member in gateway.const.SetReq
|
v_types = [member for member in gateway.const.SetReq
|
||||||
if member.value not in not_v_types]
|
if member.value not in not_v_types]
|
||||||
|
|
||||||
devices = defaultdict(list)
|
devices = {}
|
||||||
gateway.platform_callbacks.append(mysensors.pf_callback_factory(
|
gateway.platform_callbacks.append(mysensors.pf_callback_factory(
|
||||||
s_types, v_types, devices, add_devices, MySensorsSensor))
|
s_types, v_types, devices, add_devices, MySensorsSensor))
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/sensor.mysensors.html
|
https://home-assistant.io/components/sensor.mysensors.html
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchDevice
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
])
|
])
|
||||||
v_types.extend([gateway.const.SetReq.V_STATUS, ])
|
v_types.extend([gateway.const.SetReq.V_STATUS, ])
|
||||||
|
|
||||||
devices = defaultdict(list)
|
devices = {}
|
||||||
gateway.platform_callbacks.append(mysensors.pf_callback_factory(
|
gateway.platform_callbacks.append(mysensors.pf_callback_factory(
|
||||||
s_types, v_types, devices, add_devices, MySensorsSwitch))
|
s_types, v_types, devices, add_devices, MySensorsSwitch))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user