Fix polling HomeKit devices with multiple services per accessory (#25629)

This commit is contained in:
Jc2k 2019-08-01 16:35:19 +01:00 committed by GitHub
parent 6b22dbcd0b
commit 36129af447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,13 +120,21 @@ class HomeKitEntity(Entity):
"""Collect new data from bridge and update the entity state in hass.""" """Collect new data from bridge and update the entity state in hass."""
accessory_state = self._accessory.current_state.get(self._aid, {}) accessory_state = self._accessory.current_state.get(self._aid, {})
for iid, result in accessory_state.items(): for iid, result in accessory_state.items():
# No value so dont process this result
if "value" not in result: if "value" not in result:
continue continue
# 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
# Callback to update the entity with this characteristic value # Callback to update the entity with this characteristic value
char_name = escape_characteristic_name(self._char_names[iid]) char_name = escape_characteristic_name(self._char_names[iid])
update_fn = getattr(self, "_update_{}".format(char_name), None) update_fn = getattr(self, "_update_{}".format(char_name), None)
if not update_fn: if not update_fn:
continue continue
# pylint: disable=not-callable # pylint: disable=not-callable
update_fn(result["value"]) update_fn(result["value"])