1 """Support for Roborock button."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
7 from roborock.roborock_typing
import RoborockCommand
14 from .
import RoborockConfigEntry
15 from .coordinator
import RoborockDataUpdateCoordinator
16 from .entity
import RoborockEntityV1
19 @dataclass(frozen=True, kw_only=True)
21 """Describes a Roborock button entity."""
23 command: RoborockCommand
24 param: list | dict |
None
27 CONSUMABLE_BUTTON_DESCRIPTIONS = [
29 key=
"reset_sensor_consumable",
30 translation_key=
"reset_sensor_consumable",
31 command=RoborockCommand.RESET_CONSUMABLE,
32 param=[
"sensor_dirty_time"],
33 entity_category=EntityCategory.CONFIG,
34 entity_registry_enabled_default=
False,
37 key=
"reset_air_filter_consumable",
38 translation_key=
"reset_air_filter_consumable",
39 command=RoborockCommand.RESET_CONSUMABLE,
40 param=[
"filter_work_time"],
41 entity_category=EntityCategory.CONFIG,
42 entity_registry_enabled_default=
False,
45 key=
"reset_side_brush_consumable",
46 translation_key=
"reset_side_brush_consumable",
47 command=RoborockCommand.RESET_CONSUMABLE,
48 param=[
"side_brush_work_time"],
49 entity_category=EntityCategory.CONFIG,
50 entity_registry_enabled_default=
False,
53 key=
"reset_main_brush_consumable",
54 translation_key=
"reset_main_brush_consumable",
55 command=RoborockCommand.RESET_CONSUMABLE,
56 param=[
"main_brush_work_time"],
57 entity_category=EntityCategory.CONFIG,
58 entity_registry_enabled_default=
False,
65 config_entry: RoborockConfigEntry,
66 async_add_entities: AddEntitiesCallback,
68 """Set up Roborock button platform."""
74 for coordinator
in config_entry.runtime_data.v1
75 for description
in CONSUMABLE_BUTTON_DESCRIPTIONS
76 if isinstance(coordinator, RoborockDataUpdateCoordinator)
81 """A class to define Roborock button entities."""
83 entity_description: RoborockButtonDescription
87 coordinator: RoborockDataUpdateCoordinator,
88 entity_description: RoborockButtonDescription,
90 """Create a button entity."""
92 f
"{entity_description.key}_{coordinator.duid_slug}",
93 coordinator.device_info,
99 """Press the button."""
dict send(self, RoborockCommand|str command, dict[str, Any]|list[Any]|int|None params=None)