Skip to content
Snippets Groups Projects
Unverified Commit 2d210152 authored by Jeef's avatar Jeef Committed by GitHub
Browse files

Intellifire Diagnostic Sensors (#66597)

parent 30e24117
No related branches found
No related tags found
No related merge requests found
...@@ -16,11 +16,12 @@ from homeassistant.components.sensor import ( ...@@ -16,11 +16,12 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import TEMP_CELSIUS
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
from . import IntellifireDataUpdateCoordinator
from .const import DOMAIN from .const import DOMAIN
from .coordinator import IntellifireDataUpdateCoordinator
from .entity import IntellifireEntity from .entity import IntellifireEntity
...@@ -46,6 +47,13 @@ def _time_remaining_to_timestamp(data: IntellifirePollData) -> datetime | None: ...@@ -46,6 +47,13 @@ def _time_remaining_to_timestamp(data: IntellifirePollData) -> datetime | None:
return utcnow() + timedelta(seconds=seconds_offset) 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, ...] = ( INTELLIFIRE_SENSORS: tuple[IntellifireSensorEntityDescription, ...] = (
IntellifireSensorEntityDescription( IntellifireSensorEntityDescription(
key="flame_height", key="flame_height",
...@@ -85,6 +93,40 @@ INTELLIFIRE_SENSORS: tuple[IntellifireSensorEntityDescription, ...] = ( ...@@ -85,6 +93,40 @@ INTELLIFIRE_SENSORS: tuple[IntellifireSensorEntityDescription, ...] = (
device_class=SensorDeviceClass.TIMESTAMP, device_class=SensorDeviceClass.TIMESTAMP,
value_fn=_time_remaining_to_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,
),
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment