From e99f55c53d5bb07b3cb84130de062aa582e6d0f9 Mon Sep 17 00:00:00 2001 From: John Carr Date: Thu, 1 Aug 2019 14:30:47 +0100 Subject: [PATCH 1/2] Fix polling HomeKit devices with multiple services per accessory --- homeassistant/components/homekit_controller/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/homeassistant/components/homekit_controller/__init__.py b/homeassistant/components/homekit_controller/__init__.py index fd9c960980cd4..379540de6a390 100644 --- a/homeassistant/components/homekit_controller/__init__.py +++ b/homeassistant/components/homekit_controller/__init__.py @@ -120,13 +120,21 @@ def async_state_changed(self): """Collect new data from bridge and update the entity state in hass.""" accessory_state = self._accessory.current_state.get(self._aid, {}) for iid, result in accessory_state.items(): + # No value so dont process this result if "value" not in result: continue + + # Unknown iid - this is probably for a sibling service thats part + # of the same physical accessory. Ignore it. + if iid not in self._char_names: + continue + # Callback to update the entity with this characteristic value char_name = escape_characteristic_name(self._char_names[iid]) update_fn = getattr(self, "_update_{}".format(char_name), None) if not update_fn: continue + # pylint: disable=not-callable update_fn(result["value"]) From 46f5bd555498fe4e123af9b371578888b0453b5b Mon Sep 17 00:00:00 2001 From: Jc2k Date: Thu, 1 Aug 2019 15:51:50 +0100 Subject: [PATCH 2/2] Update homeassistant/components/homekit_controller/__init__.py Co-Authored-By: Martin Hjelmare --- homeassistant/components/homekit_controller/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/homekit_controller/__init__.py b/homeassistant/components/homekit_controller/__init__.py index 379540de6a390..79636cea9f391 100644 --- a/homeassistant/components/homekit_controller/__init__.py +++ b/homeassistant/components/homekit_controller/__init__.py @@ -124,7 +124,7 @@ def async_state_changed(self): if "value" not in result: continue - # Unknown iid - this is probably for a sibling service thats part + # Unknown iid - this is probably for a sibling service that is part # of the same physical accessory. Ignore it. if iid not in self._char_names: continue