From 6a4c25b668265621204af818014f89fac1fb4d3f Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 21 Apr 2020 14:12:08 +0200 Subject: [PATCH] Switch airly to async_on_remove (#34498) --- homeassistant/components/airly/air_quality.py | 8 +++----- homeassistant/components/airly/sensor.py | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/airly/air_quality.py b/homeassistant/components/airly/air_quality.py index fa42e58e9ad..deeff9af00f 100644 --- a/homeassistant/components/airly/air_quality.py +++ b/homeassistant/components/airly/air_quality.py @@ -128,11 +128,9 @@ class AirlyAirQuality(AirQualityEntity): async def async_added_to_hass(self): """Connect to dispatcher listening for entity data notifications.""" - self.coordinator.async_add_listener(self.async_write_ha_state) - - async def async_will_remove_from_hass(self): - """Disconnect from update signal.""" - self.coordinator.async_remove_listener(self.async_write_ha_state) + self.async_on_remove( + self.coordinator.async_add_listener(self.async_write_ha_state) + ) async def async_update(self): """Update Airly entity.""" diff --git a/homeassistant/components/airly/sensor.py b/homeassistant/components/airly/sensor.py index 0ee9fb3aac5..ec7b8cb3c76 100644 --- a/homeassistant/components/airly/sensor.py +++ b/homeassistant/components/airly/sensor.py @@ -149,11 +149,9 @@ class AirlySensor(Entity): async def async_added_to_hass(self): """Connect to dispatcher listening for entity data notifications.""" - self.coordinator.async_add_listener(self.async_write_ha_state) - - async def async_will_remove_from_hass(self): - """Disconnect from update signal.""" - self.coordinator.async_remove_listener(self.async_write_ha_state) + self.async_on_remove( + self.coordinator.async_add_listener(self.async_write_ha_state) + ) async def async_update(self): """Update Airly entity."""