3 from __future__
import annotations
7 from chip.clusters
import Objects
as clusters
8 from matter_server.client.models
import device_types
13 SwitchEntityDescription,
20 from .entity
import MatterEntity
21 from .helpers
import get_matter
22 from .models
import MatterDiscoverySchema
27 config_entry: ConfigEntry,
28 async_add_entities: AddEntitiesCallback,
30 """Set up Matter switches from Config Entry."""
32 matter.register_platform_handler(Platform.SWITCH, async_add_entities)
36 """Representation of a Matter switch."""
38 _platform_translation_key =
"switch"
43 node_id=self.
_endpoint_endpoint.node.node_id,
44 endpoint_id=self.
_endpoint_endpoint.endpoint_id,
45 command=clusters.OnOff.Commands.On(),
49 """Turn switch off."""
51 node_id=self.
_endpoint_endpoint.node.node_id,
52 endpoint_id=self.
_endpoint_endpoint.endpoint_id,
53 command=clusters.OnOff.Commands.Off(),
58 """Update from device."""
67 platform=Platform.SWITCH,
70 device_class=SwitchDeviceClass.OUTLET,
73 entity_class=MatterSwitch,
74 required_attributes=(clusters.OnOff.Attributes.OnOff,),
75 device_type=(device_types.OnOffPlugInUnit,),
78 platform=Platform.SWITCH,
80 key=
"MatterPowerToggle",
81 device_class=SwitchDeviceClass.SWITCH,
82 translation_key=
"power",
84 entity_class=MatterSwitch,
85 required_attributes=(clusters.OnOff.Attributes.OnOff,),
87 device_types.AirPurifier,
88 device_types.BasicVideoPlayer,
89 device_types.CastingVideoPlayer,
90 device_types.CookSurface,
92 device_types.Dishwasher,
93 device_types.ExtractorHood,
94 device_types.HeatingCoolingUnit,
95 device_types.LaundryDryer,
96 device_types.LaundryWasher,
99 device_types.PumpController,
100 device_types.Refrigerator,
101 device_types.RoboticVacuumCleaner,
102 device_types.RoomAirConditioner,
103 device_types.Speaker,
107 platform=Platform.SWITCH,
110 device_class=SwitchDeviceClass.OUTLET,
113 entity_class=MatterSwitch,
114 required_attributes=(clusters.OnOff.Attributes.OnOff,),
116 device_types.ColorTemperatureLight,
117 device_types.DimmableLight,
118 device_types.ExtendedColorLight,
119 device_types.DimmerSwitch,
120 device_types.ColorDimmerSwitch,
121 device_types.OnOffLight,
122 device_types.AirPurifier,
123 device_types.BasicVideoPlayer,
124 device_types.CastingVideoPlayer,
125 device_types.CookSurface,
126 device_types.Cooktop,
127 device_types.Dishwasher,
128 device_types.ExtractorHood,
130 device_types.HeatingCoolingUnit,
131 device_types.LaundryDryer,
132 device_types.LaundryWasher,
135 device_types.PumpController,
136 device_types.Refrigerator,
137 device_types.RoboticVacuumCleaner,
138 device_types.RoomAirConditioner,
139 device_types.Speaker,
Any get_matter_attribute_value(self, type[ClusterAttributeDescriptor] attribute, bool null_as_none=True)
None _update_from_device(self)
None async_turn_on(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
MatterAdapter get_matter(HomeAssistant hass)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)