1 """Matter Button platform."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
7 from typing
import TYPE_CHECKING, Any
9 from chip.clusters
import Objects
as clusters
14 ButtonEntityDescription,
21 from .entity
import MatterEntity, MatterEntityDescription
22 from .helpers
import get_matter
23 from .models
import MatterDiscoverySchema
28 config_entry: ConfigEntry,
29 async_add_entities: AddEntitiesCallback,
31 """Set up Matter Button platform."""
33 matter.register_platform_handler(Platform.BUTTON, async_add_entities)
36 @dataclass(frozen=True)
38 """Describe Matter Button entities."""
40 command: Callable[[], Any] |
None =
None
44 """Representation of a Matter Button entity."""
46 entity_description: MatterButtonEntityDescription
49 """Handle the button press leveraging a Matter command."""
53 node_id=self.
_endpoint_endpoint.node.node_id,
54 endpoint_id=self.
_endpoint_endpoint.endpoint_id,
62 platform=Platform.BUTTON,
65 entity_category=EntityCategory.CONFIG,
66 device_class=ButtonDeviceClass.IDENTIFY,
67 command=
lambda: clusters.Identify.Commands.Identify(identifyTime=15),
69 entity_class=MatterCommandButton,
70 required_attributes=(clusters.Identify.Attributes.AcceptedCommandList,),
71 value_contains=clusters.Identify.Commands.Identify.command_id,
75 platform=Platform.BUTTON,
77 key=
"OperationalStatePauseButton",
78 translation_key=
"pause",
79 command=clusters.OperationalState.Commands.Pause,
81 entity_class=MatterCommandButton,
82 required_attributes=(clusters.OperationalState.Attributes.AcceptedCommandList,),
83 value_contains=clusters.OperationalState.Commands.Pause.command_id,
87 platform=Platform.BUTTON,
89 key=
"OperationalStateResumeButton",
90 translation_key=
"resume",
91 command=clusters.OperationalState.Commands.Resume,
93 entity_class=MatterCommandButton,
94 required_attributes=(clusters.OperationalState.Attributes.AcceptedCommandList,),
95 value_contains=clusters.OperationalState.Commands.Resume.command_id,
99 platform=Platform.BUTTON,
101 key=
"OperationalStateStartButton",
102 translation_key=
"start",
103 command=clusters.OperationalState.Commands.Start,
105 entity_class=MatterCommandButton,
106 required_attributes=(clusters.OperationalState.Attributes.AcceptedCommandList,),
107 value_contains=clusters.OperationalState.Commands.Start.command_id,
111 platform=Platform.BUTTON,
113 key=
"OperationalStateStopButton",
114 translation_key=
"stop",
115 command=clusters.OperationalState.Commands.Stop,
117 entity_class=MatterCommandButton,
118 required_attributes=(clusters.OperationalState.Attributes.AcceptedCommandList,),
119 value_contains=clusters.OperationalState.Commands.Stop.command_id,
123 platform=Platform.BUTTON,
125 key=
"HepaFilterMonitoringResetButton",
126 translation_key=
"reset_filter_condition",
127 command=clusters.HepaFilterMonitoring.Commands.ResetCondition,
129 entity_class=MatterCommandButton,
130 required_attributes=(
131 clusters.HepaFilterMonitoring.Attributes.AcceptedCommandList,
133 value_contains=clusters.HepaFilterMonitoring.Commands.ResetCondition.command_id,
137 platform=Platform.BUTTON,
139 key=
"ActivatedCarbonFilterMonitoringResetButton",
140 translation_key=
"reset_filter_condition",
141 command=clusters.ActivatedCarbonFilterMonitoring.Commands.ResetCondition,
143 entity_class=MatterCommandButton,
144 required_attributes=(
145 clusters.ActivatedCarbonFilterMonitoring.Attributes.AcceptedCommandList,
147 value_contains=clusters.ActivatedCarbonFilterMonitoring.Commands.ResetCondition.command_id,
MatterAdapter get_matter(HomeAssistant hass)