1 """Support for Renault binary sensors."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
7 from renault_api.kamereon.enums
import ChargeState, PlugState
8 from renault_api.kamereon.models
import KamereonVehicleBatteryStatusData
11 BinarySensorDeviceClass,
13 BinarySensorEntityDescription,
19 from .
import RenaultConfigEntry
20 from .entity
import RenaultDataEntity, RenaultDataEntityDescription
23 @dataclass(frozen=True, kw_only=True)
25 BinarySensorEntityDescription,
26 RenaultDataEntityDescription,
28 """Class describing Renault binary sensor entities."""
31 on_value: StateType | list[StateType]
36 config_entry: RenaultConfigEntry,
37 async_add_entities: AddEntitiesCallback,
39 """Set up the Renault entities from config entry."""
40 entities: list[RenaultBinarySensor] = [
42 for vehicle
in config_entry.runtime_data.vehicles.values()
43 for description
in BINARY_SENSOR_TYPES
44 if description.coordinator
in vehicle.coordinators
50 RenaultDataEntity[KamereonVehicleBatteryStatusData], BinarySensorEntity
52 """Mixin for binary sensor specific attributes."""
54 entity_description: RenaultBinarySensorEntityDescription
58 """Return true if the binary sensor is on."""
67 BINARY_SENSOR_TYPES: tuple[RenaultBinarySensorEntityDescription, ...] =
tuple(
71 coordinator=
"battery",
72 device_class=BinarySensorDeviceClass.PLUG,
75 PlugState.PLUGGED.value,
76 PlugState.PLUGGED_WAITING_FOR_CHARGE.value,
81 coordinator=
"battery",
82 device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
83 on_key=
"chargingStatus",
84 on_value=ChargeState.CHARGE_IN_PROGRESS.value,
88 coordinator=
"hvac_status",
91 translation_key=
"hvac_status",
95 coordinator=
"lock_status",
97 device_class=BinarySensorDeviceClass.LOCK,
103 coordinator=
"lock_status",
105 device_class=BinarySensorDeviceClass.DOOR,
106 on_key=
"hatchStatus",
108 translation_key=
"hatch_status",
113 key=f
"{door.replace(' ', '_').lower()}_door_status",
114 coordinator=
"lock_status",
116 device_class=BinarySensorDeviceClass.DOOR,
117 on_key=f
"doorStatus{door.replace(' ', '')}",
119 translation_key=f
"{door.lower().replace(' ', '_')}_door_status",
121 for door
in (
"Rear Left",
"Rear Right",
"Driver",
"Passenger")
StateType _get_data_attr(self, str key)
None async_setup_entry(HomeAssistant hass, RenaultConfigEntry config_entry, AddEntitiesCallback async_add_entities)