mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Intellifire Diagnostic Sensors (#66597)
This commit is contained in:
parent
30e2411761
commit
2d2101528c
@ -16,11 +16,12 @@ from homeassistant.components.sensor import (
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import TEMP_CELSIUS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from . import IntellifireDataUpdateCoordinator
|
||||
from .const import DOMAIN
|
||||
from .coordinator import IntellifireDataUpdateCoordinator
|
||||
from .entity import IntellifireEntity
|
||||
|
||||
|
||||
@ -46,6 +47,13 @@ def _time_remaining_to_timestamp(data: IntellifirePollData) -> datetime | None:
|
||||
return utcnow() + timedelta(seconds=seconds_offset)
|
||||
|
||||
|
||||
def _downtime_to_timestamp(data: IntellifirePollData) -> datetime | None:
|
||||
"""Define a sensor that takes into account a timezone."""
|
||||
if not (seconds_offset := data.downtime):
|
||||
return None
|
||||
return utcnow() - timedelta(seconds=seconds_offset)
|
||||
|
||||
|
||||
INTELLIFIRE_SENSORS: tuple[IntellifireSensorEntityDescription, ...] = (
|
||||
IntellifireSensorEntityDescription(
|
||||
key="flame_height",
|
||||
@ -85,6 +93,40 @@ INTELLIFIRE_SENSORS: tuple[IntellifireSensorEntityDescription, ...] = (
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
value_fn=_time_remaining_to_timestamp,
|
||||
),
|
||||
IntellifireSensorEntityDescription(
|
||||
key="downtime",
|
||||
name="Downtime",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
value_fn=_downtime_to_timestamp,
|
||||
),
|
||||
IntellifireSensorEntityDescription(
|
||||
key="uptime",
|
||||
name="Uptime",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
value_fn=lambda data: utcnow() - timedelta(seconds=data.uptime),
|
||||
),
|
||||
IntellifireSensorEntityDescription(
|
||||
key="connection_quality",
|
||||
name="Connection Quality",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
value_fn=lambda data: data.connection_quality,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IntellifireSensorEntityDescription(
|
||||
key="ecm_latency",
|
||||
name="ECM Latency",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
value_fn=lambda data: data.ecm_latency,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IntellifireSensorEntityDescription(
|
||||
key="ipv4_address",
|
||||
name="IP",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
value_fn=lambda data: data.ipv4_address,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user