mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Switch myq to async_on_remove (#34473)
This commit is contained in:
parent
a5af746013
commit
01581ff92e
@ -5,7 +5,6 @@ from homeassistant.components.binary_sensor import (
|
|||||||
DEVICE_CLASS_CONNECTIVITY,
|
DEVICE_CLASS_CONNECTIVITY,
|
||||||
BinarySensorDevice,
|
BinarySensorDevice,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -95,14 +94,8 @@ class MyQBinarySensorDevice(BinarySensorDevice):
|
|||||||
"""Return False, updates are controlled via coordinator."""
|
"""Return False, updates are controlled via coordinator."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@callback
|
|
||||||
def _async_consume_update(self):
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Subscribe to updates."""
|
"""Subscribe to updates."""
|
||||||
self._coordinator.async_add_listener(self._async_consume_update)
|
self.async_on_remove(
|
||||||
|
self._coordinator.async_add_listener(self.async_write_ha_state)
|
||||||
async def async_will_remove_from_hass(self):
|
)
|
||||||
"""Undo subscription."""
|
|
||||||
self._coordinator.async_remove_listener(self._async_consume_update)
|
|
||||||
|
@ -209,10 +209,11 @@ class MyQDevice(CoverDevice):
|
|||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Subscribe to updates."""
|
"""Subscribe to updates."""
|
||||||
self._coordinator.async_add_listener(self._async_consume_update)
|
self.async_on_remove(
|
||||||
|
self._coordinator.async_add_listener(self._async_consume_update)
|
||||||
|
)
|
||||||
|
|
||||||
async def async_will_remove_from_hass(self):
|
async def async_will_remove_from_hass(self):
|
||||||
"""Undo subscription."""
|
"""Undo subscription."""
|
||||||
self._coordinator.async_remove_listener(self._async_consume_update)
|
|
||||||
if self._scheduled_transition_update:
|
if self._scheduled_transition_update:
|
||||||
self._scheduled_transition_update()
|
self._scheduled_transition_update()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user