mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use entity class attributes for Cert expiry (#53363)
* Use entity class attributes for cert_expiry * Use entity class attributes for cert_expiry
This commit is contained in:
parent
0b6e1d3d82
commit
1d44bfcfb6
@ -62,10 +62,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||||||
class CertExpiryEntity(CoordinatorEntity):
|
class CertExpiryEntity(CoordinatorEntity):
|
||||||
"""Defines a base Cert Expiry entity."""
|
"""Defines a base Cert Expiry entity."""
|
||||||
|
|
||||||
@property
|
_attr_icon = "mdi:certificate"
|
||||||
def icon(self):
|
|
||||||
"""Icon to use in the frontend, if any."""
|
|
||||||
return "mdi:certificate"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
@ -79,15 +76,13 @@ class CertExpiryEntity(CoordinatorEntity):
|
|||||||
class SSLCertificateTimestamp(CertExpiryEntity, SensorEntity):
|
class SSLCertificateTimestamp(CertExpiryEntity, SensorEntity):
|
||||||
"""Implementation of the Cert Expiry timestamp sensor."""
|
"""Implementation of the Cert Expiry timestamp sensor."""
|
||||||
|
|
||||||
@property
|
_attr_device_class = DEVICE_CLASS_TIMESTAMP
|
||||||
def device_class(self):
|
|
||||||
"""Return the device class of the sensor."""
|
|
||||||
return DEVICE_CLASS_TIMESTAMP
|
|
||||||
|
|
||||||
@property
|
def __init__(self, coordinator) -> None:
|
||||||
def name(self):
|
"""Initialize a Cert Expiry timestamp sensor."""
|
||||||
"""Return the name of the sensor."""
|
super().__init__(coordinator)
|
||||||
return f"Cert Expiry Timestamp ({self.coordinator.name})"
|
self._attr_name = f"Cert Expiry Timestamp ({coordinator.name})"
|
||||||
|
self._attr_unique_id = f"{coordinator.host}:{coordinator.port}-timestamp"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
@ -95,8 +90,3 @@ class SSLCertificateTimestamp(CertExpiryEntity, SensorEntity):
|
|||||||
if self.coordinator.data:
|
if self.coordinator.data:
|
||||||
return self.coordinator.data.isoformat()
|
return self.coordinator.data.isoformat()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self):
|
|
||||||
"""Return a unique id for the sensor."""
|
|
||||||
return f"{self.coordinator.host}:{self.coordinator.port}-timestamp"
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user