From d3b845c01a167097ac8da49fcca880ebb4468eee Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Sun, 30 Aug 2020 18:32:32 +0200 Subject: [PATCH] Update tile to use CoordinatorEntity (#39439) --- homeassistant/components/tile/__init__.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/tile/__init__.py b/homeassistant/components/tile/__init__.py index 58295c98bef..ad4a8886873 100644 --- a/homeassistant/components/tile/__init__.py +++ b/homeassistant/components/tile/__init__.py @@ -8,8 +8,11 @@ from pytile.errors import SessionExpiredError, TileError from homeassistant.const import ATTR_ATTRIBUTION, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import callback from homeassistant.helpers import aiohttp_client -from homeassistant.helpers.entity import Entity -from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed +from homeassistant.helpers.update_coordinator import ( + CoordinatorEntity, + DataUpdateCoordinator, + UpdateFailed, +) from .const import DATA_COORDINATOR, DOMAIN, LOGGER @@ -85,15 +88,15 @@ async def async_unload_entry(hass, config_entry): return unload_ok -class TileEntity(Entity): +class TileEntity(CoordinatorEntity): """Define a generic Tile entity.""" def __init__(self, coordinator): """Initialize.""" + super().__init__(coordinator) self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION} self._name = None self._unique_id = None - self.coordinator = coordinator @property def device_state_attributes(self): @@ -110,11 +113,6 @@ class TileEntity(Entity): """Return the name.""" return self._name - @property - def should_poll(self): - """Disable polling.""" - return False - @property def unique_id(self): """Return the unique ID of the entity.""" @@ -137,10 +135,3 @@ class TileEntity(Entity): self.async_on_remove(self.coordinator.async_add_listener(update)) self._update_from_latest_data() - - async def async_update(self): - """Update the entity. - - Only used by the generic entity update service. - """ - await self.coordinator.async_request_refresh()