Add device to cert expiry (#98152)

* Add device to cert expiry

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Joost Lekkerkerker 2023-08-10 13:05:58 +02:00 committed by GitHub
parent 4531dbbe62
commit e9f9c7799a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,8 @@ from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_START
from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
@ -99,6 +101,11 @@ class SSLCertificateTimestamp(CertExpiryEntity, SensorEntity):
super().__init__(coordinator)
self._attr_name = f"Cert Expiry Timestamp ({coordinator.name})"
self._attr_unique_id = f"{coordinator.host}:{coordinator.port}-timestamp"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, f"{coordinator.host}:{coordinator.port}")},
name=coordinator.name,
entry_type=DeviceEntryType.SERVICE,
)
@property
def native_value(self) -> datetime | None: