1 """Home Assistant component for accessing the Wallbox Portal API. The switch component creates a switch entity."""
3 from __future__
import annotations
14 CHARGER_PAUSE_RESUME_KEY,
15 CHARGER_SERIAL_NUMBER_KEY,
16 CHARGER_STATUS_DESCRIPTION_KEY,
20 from .coordinator
import WallboxCoordinator
21 from .entity
import WallboxEntity
23 SWITCH_TYPES: dict[str, SwitchEntityDescription] = {
25 key=CHARGER_PAUSE_RESUME_KEY,
26 translation_key=
"pause_resume",
32 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
34 """Create wallbox sensor entities in HASS."""
35 coordinator: WallboxCoordinator = hass.data[DOMAIN][entry.entry_id]
37 [
WallboxSwitch(coordinator, SWITCH_TYPES[CHARGER_PAUSE_RESUME_KEY])]
42 """Representation of the Wallbox portal."""
46 coordinator: WallboxCoordinator,
47 description: SwitchEntityDescription,
49 """Initialize a Wallbox switch."""
52 self.
_attr_unique_id_attr_unique_id = f
"{description.key}-{coordinator.data[CHARGER_DATA_KEY][CHARGER_SERIAL_NUMBER_KEY]}"
56 """Return the availability of the switch."""
57 return super().available
and self.coordinator.data[
58 CHARGER_STATUS_DESCRIPTION_KEY
60 ChargerStatus.UNKNOWN,
61 ChargerStatus.UPDATING,
64 ChargerStatus.LOCKED_CAR_CONNECTED,
65 ChargerStatus.DISCONNECTED,
71 """Return the status of pause/resume."""
72 return self.coordinator.data[CHARGER_STATUS_DESCRIPTION_KEY]
in {
73 ChargerStatus.CHARGING,
74 ChargerStatus.DISCHARGING,
75 ChargerStatus.WAITING_FOR_CAR,
76 ChargerStatus.WAITING,
None async_pause_charger(self, bool pause)
None __init__(self, WallboxCoordinator coordinator, SwitchEntityDescription description)
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)