Push mysensor state instead of polling.
parent
c72a735851
commit
0e9d826d41
|
@ -37,9 +37,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
devices[nid] = MySensorsNode(sensor.sketch_name)
|
||||
add_devices([devices[nid]])
|
||||
|
||||
devices[nid].battery_level = sensor.battery_level
|
||||
node = devices[nid]
|
||||
node.battery_level = sensor.battery_level
|
||||
for child_id, child in sensor.children.items():
|
||||
devices[nid].update_child(child_id, child)
|
||||
node.update_child(child_id, child)
|
||||
node.update_ha_state()
|
||||
|
||||
port = config.get(CONF_PORT)
|
||||
if port is None:
|
||||
|
@ -60,6 +62,11 @@ class MySensorsNode(Entity):
|
|||
self.battery_level = 0
|
||||
self.children = {}
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
""" MySensor gateway pushes its state to HA. """
|
||||
return False
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" The name of this sensor. """
|
||||
|
|
Loading…
Reference in New Issue