1 """Support for Roku binary sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
8 from rokuecp.models
import Device
as RokuDevice
12 BinarySensorEntityDescription,
19 from .const
import DOMAIN
20 from .entity
import RokuEntity
23 @dataclass(frozen=True, kw_only=True)
25 """Describes a Roku binary sensor entity."""
27 value_fn: Callable[[RokuDevice], bool |
None]
30 BINARY_SENSORS: tuple[RokuBinarySensorEntityDescription, ...] = (
32 key=
"headphones_connected",
33 translation_key=
"headphones_connected",
34 value_fn=
lambda device: device.info.headphones_connected,
37 key=
"supports_airplay",
38 translation_key=
"supports_airplay",
39 entity_category=EntityCategory.DIAGNOSTIC,
40 value_fn=
lambda device: device.info.supports_airplay,
43 key=
"supports_ethernet",
44 translation_key=
"supports_ethernet",
45 entity_category=EntityCategory.DIAGNOSTIC,
46 value_fn=
lambda device: device.info.ethernet_support,
49 key=
"supports_find_remote",
50 translation_key=
"supports_find_remote",
51 entity_category=EntityCategory.DIAGNOSTIC,
52 value_fn=
lambda device: device.info.supports_find_remote,
60 async_add_entities: AddEntitiesCallback,
62 """Set up a Roku binary sensors based on a config entry."""
63 coordinator = hass.data[DOMAIN][entry.entry_id]
67 coordinator=coordinator,
68 description=description,
70 for description
in BINARY_SENSORS
75 """Defines a Roku binary sensor."""
77 entity_description: RokuBinarySensorEntityDescription
81 """Return the state of the sensor."""
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)