mirror of
https://github.com/home-assistant/core.git
synced 2026-07-01 11:46:40 +01:00
d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""Support for Magic Home sensors."""
|
|
|
|
from homeassistant.components.sensor import SensorEntity
|
|
from homeassistant.const import EntityCategory
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
|
|
|
from .coordinator import FluxLedConfigEntry
|
|
from .entity import FluxEntity
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
entry: FluxLedConfigEntry,
|
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
|
) -> None:
|
|
"""Set up the Magic Home sensors."""
|
|
coordinator = entry.runtime_data
|
|
if coordinator.device.paired_remotes is not None:
|
|
async_add_entities(
|
|
[
|
|
FluxPairedRemotes(
|
|
coordinator,
|
|
entry.unique_id or entry.entry_id,
|
|
"paired_remotes",
|
|
)
|
|
]
|
|
)
|
|
|
|
|
|
class FluxPairedRemotes(FluxEntity, SensorEntity):
|
|
"""Representation of a Magic Home paired remotes sensor."""
|
|
|
|
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
|
_attr_translation_key = "paired_remotes"
|
|
|
|
@property
|
|
def native_value(self) -> int:
|
|
"""Return the number of paired remotes."""
|
|
assert self._device.paired_remotes is not None
|
|
return self._device.paired_remotes
|