1 """Support for switch entities."""
3 from __future__
import annotations
7 from gardena_bluetooth.const
import Valve
14 from .
import GardenaBluetoothConfigEntry
15 from .coordinator
import GardenaBluetoothCoordinator
16 from .entity
import GardenaBluetoothEntity
21 entry: GardenaBluetoothConfigEntry,
22 async_add_entities: AddEntitiesCallback,
24 """Set up switch based on a config entry."""
25 coordinator = entry.runtime_data
27 if GardenaBluetoothValveSwitch.characteristics.issubset(
28 coordinator.characteristics
36 """Representation of a valve switch."""
40 Valve.manual_watering_time.uuid,
41 Valve.remaining_open_time.uuid,
46 coordinator: GardenaBluetoothCoordinator,
48 """Initialize the switch."""
50 coordinator, {Valve.state.uuid, Valve.manual_watering_time.uuid}
62 """Turn the entity on."""
63 if not (data := self.coordinator.data.get(Valve.manual_watering_time.uuid)):
66 value = Valve.manual_watering_time.decode(data)
67 await self.coordinator.
write(Valve.remaining_open_time, value)
72 """Turn the entity off."""
73 await self.coordinator.
write(Valve.remaining_open_time, 0)
CharacteristicType|None get_cached(self, Characteristic[CharacteristicType] char)
None write(self, Characteristic[CharacteristicType] char, CharacteristicType value)
None _handle_coordinator_update(self)
_attr_entity_registry_enabled_default
None __init__(self, GardenaBluetoothCoordinator coordinator)
None async_turn_on(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, GardenaBluetoothConfigEntry entry, AddEntitiesCallback async_add_entities)