1 """Support for V2C binary sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
8 from pytrydan
import Trydan
11 BinarySensorDeviceClass,
13 BinarySensorEntityDescription,
18 from .
import V2CConfigEntry
19 from .coordinator
import V2CUpdateCoordinator
20 from .entity
import V2CBaseEntity
23 @dataclass(frozen=True, kw_only=True)
25 """Describes an EVSE binary sensor entity."""
27 value_fn: Callable[[Trydan], bool]
33 translation_key=
"connected",
34 device_class=BinarySensorDeviceClass.PLUG,
35 value_fn=
lambda evse: evse.connected,
39 translation_key=
"charging",
40 device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
41 value_fn=
lambda evse: evse.charging,
45 translation_key=
"ready",
46 value_fn=
lambda evse: evse.ready,
53 config_entry: V2CConfigEntry,
54 async_add_entities: AddEntitiesCallback,
56 """Set up V2C binary sensor platform."""
57 coordinator = config_entry.runtime_data
61 for description
in TRYDAN_SENSORS
66 """Defines a base V2C binary_sensor entity."""
68 entity_description: V2CBinarySensorEntityDescription
72 coordinator: V2CUpdateCoordinator,
73 description: V2CBinarySensorEntityDescription,
76 """Init the V2C base entity."""
77 super().
__init__(coordinator, description)
82 """Return the state of the V2C binary_sensor."""
None __init__(self, V2CUpdateCoordinator coordinator, V2CBinarySensorEntityDescription description, str entry_id)
None async_setup_entry(HomeAssistant hass, V2CConfigEntry config_entry, AddEntitiesCallback async_add_entities)