Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 1 addition & 43 deletions tests/data/devices/tze200-2aaelwxk-ts0225.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@
"entity_category": null,
"entity_registry_enabled_default": true,
"enabled": true,
"primary": false,
"primary": true,
"cluster_handlers": [
{
"class_name": "OccupancySensingClusterHandler",
Expand Down Expand Up @@ -1427,48 +1427,6 @@
}
],
"switch": [
{
"info_object": {
"fallback_name": null,
"unique_id": "ab:cd:ef:12:94:85:f7:5f-1-6",
"migrate_unique_ids": [],
"platform": "switch",
"class_name": "Switch",
"translation_key": "switch",
"translation_placeholders": null,
"device_class": null,
"state_class": null,
"entity_category": null,
"entity_registry_enabled_default": true,
"enabled": true,
"primary": true,
"cluster_handlers": [
{
"class_name": "OnOffClusterHandler",
"generic_id": "cluster_handler_0x0006",
"endpoint_id": 1,
"cluster": {
"id": 6,
"name": "On/Off",
"type": "server"
},
"id": "1:0x0006",
"unique_id": "ab:cd:ef:12:94:85:f7:5f:1:0x0006",
"status": "INITIALIZED",
"value_attribute": "on_off"
}
],
"device_ieee": "ab:cd:ef:12:94:85:f7:5f",
"endpoint_id": 1,
"available": true,
"group_id": null
},
"state": {
"class_name": "Switch",
"state": false,
"available": true
}
},
{
"info_object": {
"fallback_name": "LED indicator",
Expand Down
17 changes: 16 additions & 1 deletion zha/application/platforms/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class Switch(PlatformEntity, BaseSwitch):

_attr_translation_key = "switch"
_attr_primary_weight = 10
_attribute_name = OnOff.AttributeDefs.on_off.name

def __init__(
self,
Expand All @@ -135,12 +136,26 @@ def on_add(self) -> None:
)
)

def _is_supported(self) -> bool:
if (
self._attribute_name
in self._on_off_cluster_handler.cluster.unsupported_attributes
):
_LOGGER.debug(
"%s is not supported - skipping %s entity creation",
self._attribute_name,
self.__class__.__name__,
)
return False

return super()._is_supported()

def handle_cluster_handler_attribute_updated(
self,
event: ClusterAttributeUpdatedEvent, # pylint: disable=unused-argument
) -> None:
"""Handle state update from cluster handler."""
if event.attribute_name == OnOff.AttributeDefs.on_off.name:
if event.attribute_name == self._attribute_name:
self.maybe_emit_state_changed_event()


Expand Down
Loading