diff --git a/homeassistant/components/cert_expiry/sensor.py b/homeassistant/components/cert_expiry/sensor.py index 55b72bdefcd..ecf6ce18342 100644 --- a/homeassistant/components/cert_expiry/sensor.py +++ b/homeassistant/components/cert_expiry/sensor.py @@ -15,8 +15,8 @@ from homeassistant.const import ( ) from homeassistant.core import callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_call_later +from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.util import dt from .const import DEFAULT_PORT, DOMAIN @@ -65,38 +65,14 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(sensors, True) -class CertExpiryEntity(Entity): +class CertExpiryEntity(CoordinatorEntity): """Defines a base Cert Expiry entity.""" - def __init__(self, coordinator): - """Initialize the Cert Expiry entity.""" - self.coordinator = coordinator - - async def async_added_to_hass(self): - """Connect to dispatcher listening for entity data notifications.""" - self.async_on_remove( - self.coordinator.async_add_listener(self.async_write_ha_state) - ) - - async def async_update(self): - """Update Cert Expiry entity.""" - await self.coordinator.async_request_refresh() - - @property - def available(self): - """Return True if entity is available.""" - return self.coordinator.last_update_success - @property def icon(self): """Icon to use in the frontend, if any.""" return "mdi:certificate" - @property - def should_poll(self): - """Return the polling requirement of the entity.""" - return False - @property def device_state_attributes(self): """Return additional sensor state attributes."""