1 """Platform for binary sensor integration."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
9 from mypermobil
import BATTERY_CHARGING
11 from homeassistant
import config_entries
14 BinarySensorEntityDescription,
19 from .const
import DOMAIN
20 from .coordinator
import MyPermobilCoordinator
21 from .entity
import PermobilEntity
24 @dataclass(frozen=True, kw_only=True)
26 """Describes Permobil binary sensor entity."""
28 is_on_fn: Callable[[Any], bool]
29 available_fn: Callable[[Any], bool]
32 BINARY_SENSOR_DESCRIPTIONS: tuple[PermobilBinarySensorEntityDescription, ...] = (
34 is_on_fn=
lambda data: data.battery[BATTERY_CHARGING[0]],
35 available_fn=
lambda data: BATTERY_CHARGING[0]
in data.battery,
37 translation_key=
"is_charging",
45 async_add_entities: AddEntitiesCallback,
47 """Create and setup the binary sensor."""
49 coordinator: MyPermobilCoordinator = hass.data[DOMAIN][config_entry.entry_id]
53 for description
in BINARY_SENSOR_DESCRIPTIONS
58 """Representation of a Binary Sensor."""
60 entity_description: PermobilBinarySensorEntityDescription
64 """Return True if the wheelchair is charging."""
69 """Return True if the sensor has value."""
None async_setup_entry(HomeAssistant hass, config_entries.ConfigEntry config_entry, AddEntitiesCallback async_add_entities)