File tree Expand file tree Collapse file tree 2 files changed +17
-44
lines changed
zha/application/platforms Expand file tree Collapse file tree 2 files changed +17
-44
lines changed Original file line number Diff line number Diff line change 501501 "entity_category" : null ,
502502 "entity_registry_enabled_default" : true ,
503503 "enabled" : true ,
504- "primary" : false ,
504+ "primary" : true ,
505505 "cluster_handlers" : [
506506 {
507507 "class_name" : " OccupancySensingClusterHandler" ,
14271427 }
14281428 ],
14291429 "switch" : [
1430- {
1431- "info_object" : {
1432- "fallback_name" : null ,
1433- "unique_id" : " ab:cd:ef:12:94:85:f7:5f-1-6" ,
1434- "migrate_unique_ids" : [],
1435- "platform" : " switch" ,
1436- "class_name" : " Switch" ,
1437- "translation_key" : " switch" ,
1438- "translation_placeholders" : null ,
1439- "device_class" : null ,
1440- "state_class" : null ,
1441- "entity_category" : null ,
1442- "entity_registry_enabled_default" : true ,
1443- "enabled" : true ,
1444- "primary" : true ,
1445- "cluster_handlers" : [
1446- {
1447- "class_name" : " OnOffClusterHandler" ,
1448- "generic_id" : " cluster_handler_0x0006" ,
1449- "endpoint_id" : 1 ,
1450- "cluster" : {
1451- "id" : 6 ,
1452- "name" : " On/Off" ,
1453- "type" : " server"
1454- },
1455- "id" : " 1:0x0006" ,
1456- "unique_id" : " ab:cd:ef:12:94:85:f7:5f:1:0x0006" ,
1457- "status" : " INITIALIZED" ,
1458- "value_attribute" : " on_off"
1459- }
1460- ],
1461- "device_ieee" : " ab:cd:ef:12:94:85:f7:5f" ,
1462- "endpoint_id" : 1 ,
1463- "available" : true ,
1464- "group_id" : null
1465- },
1466- "state" : {
1467- "class_name" : " Switch" ,
1468- "state" : false ,
1469- "available" : true
1470- }
1471- },
14721430 {
14731431 "info_object" : {
14741432 "fallback_name" : " LED indicator" ,
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ class Switch(PlatformEntity, BaseSwitch):
111111
112112 _attr_translation_key = "switch"
113113 _attr_primary_weight = 10
114+ _attribute_name = OnOff .AttributeDefs .on_off .name
114115
115116 def __init__ (
116117 self ,
@@ -135,12 +136,26 @@ def on_add(self) -> None:
135136 )
136137 )
137138
139+ def _is_supported (self ) -> bool :
140+ if (
141+ self ._attribute_name
142+ in self ._on_off_cluster_handler .cluster .unsupported_attributes
143+ ):
144+ _LOGGER .debug (
145+ "%s is not supported - skipping %s entity creation" ,
146+ self ._attribute_name ,
147+ self .__class__ .__name__ ,
148+ )
149+ return False
150+
151+ return super ()._is_supported ()
152+
138153 def handle_cluster_handler_attribute_updated (
139154 self ,
140155 event : ClusterAttributeUpdatedEvent , # pylint: disable=unused-argument
141156 ) -> None :
142157 """Handle state update from cluster handler."""
143- if event .attribute_name == OnOff . AttributeDefs . on_off . name :
158+ if event .attribute_name == self . _attribute_name :
144159 self .maybe_emit_state_changed_event ()
145160
146161
You can’t perform that action at this time.
0 commit comments