1 """Binary sensor entities for the madVR integration."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
10 BinarySensorEntityDescription,
15 from .
import MadVRConfigEntry
16 from .coordinator
import MadVRCoordinator
17 from .entity
import MadVREntity
19 _HDR_FLAG =
"hdr_flag"
20 _OUTGOING_HDR_FLAG =
"outgoing_hdr_flag"
21 _POWER_STATE =
"power_state"
22 _SIGNAL_STATE =
"signal_state"
25 @dataclass(frozen=True, kw_only=True)
27 """Describe madVR binary sensor entity."""
29 value_fn: Callable[[MadVRCoordinator], bool]
32 BINARY_SENSORS: tuple[MadvrBinarySensorEntityDescription, ...] = (
35 translation_key=_POWER_STATE,
36 value_fn=
lambda coordinator: coordinator.data.get(
"is_on",
False),
40 translation_key=_SIGNAL_STATE,
41 value_fn=
lambda coordinator: coordinator.data.get(
"is_signal",
False),
45 translation_key=_HDR_FLAG,
46 value_fn=
lambda coordinator: coordinator.data.get(
"hdr_flag",
False),
49 key=_OUTGOING_HDR_FLAG,
50 translation_key=_OUTGOING_HDR_FLAG,
51 value_fn=
lambda coordinator: coordinator.data.get(
"outgoing_hdr_flag",
False),
58 entry: MadVRConfigEntry,
59 async_add_entities: AddEntitiesCallback,
61 """Set up the binary sensor entities."""
62 coordinator = entry.runtime_data
69 """Base class for madVR binary sensors."""
71 entity_description: MadvrBinarySensorEntityDescription
75 coordinator: MadVRCoordinator,
76 description: MadvrBinarySensorEntityDescription,
78 """Initialize the binary sensor."""
85 """Return true if the binary sensor is on."""
None __init__(self, MadVRCoordinator coordinator, MadvrBinarySensorEntityDescription description)
None async_setup_entry(HomeAssistant hass, MadVRConfigEntry entry, AddEntitiesCallback async_add_entities)