Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Counter for the days until an HTTPS (TLS) certificate will expire."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from homeassistant.helpers.update_coordinator import CoordinatorEntity
8 
9 from .coordinator import CertExpiryDataUpdateCoordinator
10 
11 
12 class CertExpiryEntity(CoordinatorEntity[CertExpiryDataUpdateCoordinator]):
13  """Defines a base Cert Expiry entity."""
14 
15  _attr_has_entity_name = True
16 
17  @property
18  def extra_state_attributes(self) -> dict[str, Any]:
19  """Return additional sensor state attributes."""
20  return {
21  "is_valid": self.coordinator.is_cert_valid,
22  "error": str(self.coordinator.cert_error),
23  }