1 """Support for Litter-Robot switches."""
3 from __future__
import annotations
5 from collections.abc
import Callable, Coroutine
6 from dataclasses
import dataclass
7 from typing
import Any, Generic
9 from pylitterbot
import FeederRobot, LitterRobot
16 from .
import LitterRobotConfigEntry
17 from .entity
import LitterRobotEntity, _RobotT
20 @dataclass(frozen=True)
22 """A class that describes robot switch entity required keys."""
24 set_fn: Callable[[_RobotT, bool], Coroutine[Any, Any, bool]]
27 @dataclass(frozen=True)
29 """A class that describes robot switch entities."""
31 entity_category: EntityCategory = EntityCategory.CONFIG
35 RobotSwitchEntityDescription[LitterRobot | FeederRobot](
36 key=
"night_light_mode_enabled",
37 translation_key=
"night_light_mode",
38 set_fn=
lambda robot, value: robot.set_night_light(value),
40 RobotSwitchEntityDescription[LitterRobot | FeederRobot](
41 key=
"panel_lock_enabled",
42 translation_key=
"panel_lockout",
43 set_fn=
lambda robot, value: robot.set_panel_lockout(value),
49 """Litter-Robot switch entity."""
51 entity_description: RobotSwitchEntityDescription[_RobotT]
55 """Return true if switch is on."""
59 """Turn the switch on."""
63 """Turn the switch off."""
69 entry: LitterRobotConfigEntry,
70 async_add_entities: AddEntitiesCallback,
72 """Set up Litter-Robot switches using config entry."""
73 hub = entry.runtime_data
76 for description
in ROBOT_SWITCHES
77 for robot
in hub.account.robots
78 if isinstance(robot, (LitterRobot, FeederRobot))
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, LitterRobotConfigEntry entry, AddEntitiesCallback async_add_entities)