From f9a46cc79f82e8a493337db3efb5e6aa19cc24d7 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 26 Aug 2022 10:21:13 +0200 Subject: [PATCH] Use _attr_should_poll in econet (#77262) --- homeassistant/components/econet/__init__.py | 10 ++-------- homeassistant/components/econet/water_heater.py | 14 +++----------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/econet/__init__.py b/homeassistant/components/econet/__init__.py index 728222dcda7..981d6cbad23 100644 --- a/homeassistant/components/econet/__init__.py +++ b/homeassistant/components/econet/__init__.py @@ -111,6 +111,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: class EcoNetEntity(Entity): """Define a base EcoNet entity.""" + _attr_should_poll = False + def __init__(self, econet): """Initialize.""" self._econet = econet @@ -155,11 +157,3 @@ class EcoNetEntity(Entity): def temperature_unit(self): """Return the unit of measurement.""" return TEMP_FAHRENHEIT - - @property - def should_poll(self) -> bool: - """Return True if entity has to be polled for state. - - False if entity pushes its state to HA. - """ - return False diff --git a/homeassistant/components/econet/water_heater.py b/homeassistant/components/econet/water_heater.py index 50f080217b4..165dc49e205 100644 --- a/homeassistant/components/econet/water_heater.py +++ b/homeassistant/components/econet/water_heater.py @@ -62,7 +62,7 @@ class EcoNetWaterHeater(EcoNetEntity, WaterHeaterEntity): """Initialize.""" super().__init__(water_heater) self._running = water_heater.running - self._poll = True + self._attr_should_poll = True # Override False default from EcoNetEntity self.water_heater = water_heater self.econet_state_to_ha = {} self.ha_state_to_econet = {} @@ -72,7 +72,7 @@ class EcoNetWaterHeater(EcoNetEntity, WaterHeaterEntity): """Update was pushed from the ecoent API.""" if self._running != self.water_heater.running: # Water heater running state has changed so check usage on next update - self._poll = True + self._attr_should_poll = True self._running = self.water_heater.running self.async_write_ha_state() @@ -149,20 +149,12 @@ class EcoNetWaterHeater(EcoNetEntity, WaterHeaterEntity): """Return the maximum temperature.""" return self.water_heater.set_point_limits[1] - @property - def should_poll(self) -> bool: - """Return True if entity has to be polled for state. - - False if entity pushes its state to HA. - """ - return self._poll - async def async_update(self) -> None: """Get the latest energy usage.""" await self.water_heater.get_energy_usage() await self.water_heater.get_water_usage() self.async_write_ha_state() - self._poll = False + self._attr_should_poll = False def turn_away_mode_on(self) -> None: """Turn away mode on."""