Don't reinvent callback handler removal logic in several integ… (#33726)

This commit is contained in:
Aaron Bach authored and GitHub committed 2020-04-05 22:36:23 -07:00
1 parent e4ee4cf302
commit f53dfc4308
10 files changed
+16 -67

No files matched your search

+1 -10
View File
@@ -233,7 +233,6 @@ class OpenUvEntity(Entity):
def __init__(self, openuv):
"""Initialize."""
self._async_unsub_dispatcher_connect = None
self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
self._available = True
self._name = None
@@ -263,18 +262,10 @@ class OpenUvEntity(Entity):
self.update_from_latest_data()
self.async_write_ha_state()
self._async_unsub_dispatcher_connect = async_dispatcher_connect(
self.hass, TOPIC_UPDATE, update
)
self.async_on_remove(async_dispatcher_connect(self.hass, TOPIC_UPDATE, update))
self.update_from_latest_data()
async def async_will_remove_from_hass(self):
"""Disconnect dispatcher listener when removed."""
if self._async_unsub_dispatcher_connect:
self._async_unsub_dispatcher_connect()
self._async_unsub_dispatcher_connect = None
def update_from_latest_data(self):
"""Update the sensor using the latest data."""
raise NotImplementedError