1 """Support for Litter-Robot button."""
3 from __future__
import annotations
5 from collections.abc
import Callable, Coroutine
6 from dataclasses
import dataclass
8 from typing
import Any, Generic
10 from pylitterbot
import FeederRobot, LitterRobot3
17 from .
import LitterRobotConfigEntry
18 from .entity
import LitterRobotEntity, _RobotT
23 entry: LitterRobotConfigEntry,
24 async_add_entities: AddEntitiesCallback,
26 """Set up Litter-Robot cleaner using config entry."""
27 hub = entry.runtime_data
28 entities: list[LitterRobotButtonEntity] =
list(
32 robot=robot, hub=hub, description=LITTER_ROBOT_BUTTON
34 for robot
in hub.litter_robots()
35 if isinstance(robot, LitterRobot3)
39 robot=robot, hub=hub, description=FEEDER_ROBOT_BUTTON
41 for robot
in hub.feeder_robots()
48 @dataclass(frozen=True)
50 """A class that describes robot button entity required keys."""
52 press_fn: Callable[[_RobotT], Coroutine[Any, Any, bool]]
55 @dataclass(frozen=True)
57 """A class that describes robot button entities."""
60 LITTER_ROBOT_BUTTON = RobotButtonEntityDescription[LitterRobot3](
61 key=
"reset_waste_drawer",
62 translation_key=
"reset_waste_drawer",
63 entity_category=EntityCategory.CONFIG,
64 press_fn=
lambda robot: robot.reset_waste_drawer(),
66 FEEDER_ROBOT_BUTTON = RobotButtonEntityDescription[FeederRobot](
68 translation_key=
"give_snack",
69 press_fn=
lambda robot: robot.give_snack(),
74 """Litter-Robot button entity."""
76 entity_description: RobotButtonEntityDescription[_RobotT]
79 """Press the button."""
None async_set_updated_data(self, _DataT data)