From 2f74ffcf81e22a9c038f2591dc008b7938b96d92 Mon Sep 17 00:00:00 2001 From: Russell Cloran Date: Mon, 14 May 2018 07:50:09 -0700 Subject: [PATCH] zha: Fix cluster class check in single-cluster device type (#14303) zigpy now allows custom devices, which might mean that devices have cluster objects which are not instances of the default, but may be instances of sub-classes of the default. This fixes the check for finding single-cluster device entities to handle sub-classes properly. --- homeassistant/components/zha/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/zha/__init__.py b/homeassistant/components/zha/__init__.py index 238e89c07f0..3ea95ff1dd1 100644 --- a/homeassistant/components/zha/__init__.py +++ b/homeassistant/components/zha/__init__.py @@ -256,11 +256,16 @@ class ApplicationListener: """Try to set up an entity from a "bare" cluster.""" if cluster.cluster_id in profile_clusters: return - # pylint: disable=unidiomatic-typecheck - if type(cluster) not in device_classes: + + component = None + for cluster_type, candidate_component in device_classes.items(): + if isinstance(cluster, cluster_type): + component = candidate_component + break + + if component is None: return - component = device_classes[type(cluster)] cluster_key = "{}-{}".format(device_key, cluster.cluster_id) discovery_info = { 'application_listener': self,