Phill (pssc) a16ef5b7ff
Add squeezebox service sensors (#125349)
* Add server sensors

* Fix Platforms order

* Fix spelling

* Fix translations

* Add sensor test

* Case changes

* refactor to use native_value attr override

* Fix typing

* Fix cast to type

* add cast

* use update platform for LMS versions

* Fix translation

* remove update entity

* remove possible update entites

* Fix and clarify

* update to icon trans remove update plaform entitiy supporting items

* add UOM to sensors

* correct criptic prettier fail

* reword other players

* Apply suggestions from code review

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-09-10 17:17:26 +02:00

32 lines
1.1 KiB
Python

"""Base class for Squeezebox Sensor entities."""
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity import EntityDescription
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN, STATUS_QUERY_UUID
from .coordinator import LMSStatusDataUpdateCoordinator
class LMSStatusEntity(CoordinatorEntity[LMSStatusDataUpdateCoordinator]):
"""Defines a base status sensor entity."""
_attr_has_entity_name = True
def __init__(
self,
coordinator: LMSStatusDataUpdateCoordinator,
description: EntityDescription,
) -> None:
"""Initialize status sensor entity."""
super().__init__(coordinator)
self.entity_description = description
self._attr_translation_key = description.key.replace(" ", "_")
self._attr_unique_id = (
f"{coordinator.data[STATUS_QUERY_UUID]}_{description.key}"
)
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, coordinator.data[STATUS_QUERY_UUID])},
)