Data Coordinator to return unsub func (#33588)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-04-03 20:15:42 +02:00
1 parent d1663f2733
commit dc7127aacf
5 files changed
+34 -44

No files matched your search

+5 -10
View File
@@ -76,9 +76,8 @@ class SensorManager:
return
# We have all components available, start the updating.
self.coordinator.async_add_listener(self.async_update_items)
self.bridge.reset_jobs.append(
lambda: self.coordinator.async_remove_listener(self.async_update_items)
self.coordinator.async_add_listener(self.async_update_items)
)
await self.coordinator.async_refresh()
@@ -178,14 +177,10 @@ class GenericHueSensor(GenericHueDevice, entity.Entity):
async def async_added_to_hass(self):
"""When entity is added to hass."""
self.bridge.sensor_manager.coordinator.async_add_listener(
self.async_write_ha_state
)
async def async_will_remove_from_hass(self):
"""When entity will be removed from hass."""
self.bridge.sensor_manager.coordinator.async_remove_listener(
self.async_write_ha_state
self.async_on_remove(
self.bridge.sensor_manager.coordinator.async_add_listener(
self.async_write_ha_state
)
)
async def async_update(self):