1 """Binary Sensors for Tesla Wall Connector."""
3 from dataclasses
import dataclass
7 BinarySensorDeviceClass,
9 BinarySensorEntityDescription,
16 from .
import WallConnectorData
17 from .const
import DOMAIN, WALLCONNECTOR_DATA_VITALS
18 from .entity
import WallConnectorEntity, WallConnectorLambdaValueGetterMixin
20 _LOGGER = logging.getLogger(__name__)
23 @dataclass(frozen=True)
25 BinarySensorEntityDescription, WallConnectorLambdaValueGetterMixin
27 """Binary Sensor entity description."""
30 WALL_CONNECTOR_SENSORS = [
32 key=
"vehicle_connected",
33 translation_key=
"vehicle_connected",
34 entity_category=EntityCategory.DIAGNOSTIC,
35 value_fn=
lambda data: data[WALLCONNECTOR_DATA_VITALS].vehicle_connected,
36 device_class=BinarySensorDeviceClass.PLUG,
39 key=
"contactor_closed",
40 translation_key=
"contactor_closed",
41 entity_category=EntityCategory.DIAGNOSTIC,
42 value_fn=
lambda data: data[WALLCONNECTOR_DATA_VITALS].contactor_closed,
43 device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
50 config_entry: ConfigEntry,
51 async_add_entities: AddEntitiesCallback,
53 """Create the Wall Connector sensor devices."""
54 wall_connector_data = hass.data[DOMAIN][config_entry.entry_id]
58 for description
in WALL_CONNECTOR_SENSORS
65 """Wall Connector Sensor Entity."""
69 wall_connectord_data: WallConnectorData,
70 description: WallConnectorBinarySensorDescription,
72 """Initialize WallConnectorBinarySensorEntity."""
74 super().
__init__(wall_connectord_data)
78 """Return the state of the sensor."""
None __init__(self, WallConnectorData wall_connectord_data, WallConnectorBinarySensorDescription description)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)