mirror of
https://github.com/home-assistant/core.git
synced 2026-02-22 02:47:14 +00:00
124 lines
3.5 KiB
Python
124 lines
3.5 KiB
Python
"""Sensor platform for HDFury Integration."""
|
|
|
|
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
|
from homeassistant.const import EntityCategory
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
|
|
|
from .coordinator import HDFuryConfigEntry
|
|
from .entity import HDFuryEntity
|
|
|
|
PARALLEL_UPDATES = 0
|
|
|
|
SENSORS: tuple[SensorEntityDescription, ...] = (
|
|
SensorEntityDescription(
|
|
key="RX0",
|
|
translation_key="rx0",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="RX1",
|
|
translation_key="rx1",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="TX0",
|
|
translation_key="tx0",
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="TX1",
|
|
translation_key="tx1",
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="AUD0",
|
|
translation_key="aud0",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="AUD1",
|
|
translation_key="aud1",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="AUDOUT",
|
|
translation_key="audout",
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="EARCRX",
|
|
translation_key="earcrx",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="SINK0",
|
|
translation_key="sink0",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="SINK1",
|
|
translation_key="sink1",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="SINK2",
|
|
translation_key="sink2",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="EDIDA0",
|
|
translation_key="edida0",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="EDIDA1",
|
|
translation_key="edida1",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
SensorEntityDescription(
|
|
key="EDIDA2",
|
|
translation_key="edida2",
|
|
entity_registry_enabled_default=False,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
)
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
entry: HDFuryConfigEntry,
|
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
|
) -> None:
|
|
"""Set up sensors using the platform schema."""
|
|
|
|
coordinator = entry.runtime_data
|
|
|
|
async_add_entities(
|
|
HDFurySensor(coordinator, description)
|
|
for description in SENSORS
|
|
if description.key in coordinator.data.info
|
|
)
|
|
|
|
|
|
class HDFurySensor(HDFuryEntity, SensorEntity):
|
|
"""Base HDFury Sensor Class."""
|
|
|
|
entity_description: SensorEntityDescription
|
|
|
|
@property
|
|
def native_value(self) -> str:
|
|
"""Set Sensor Value."""
|
|
|
|
return self.coordinator.data.info[self.entity_description.key]
|