From 6e831138b407776de549b29907c9efb04fe0a0ea Mon Sep 17 00:00:00 2001 From: damarco Date: Thu, 10 May 2018 19:59:23 +0200 Subject: [PATCH] Fix binary_sensor async_update (#14376) --- homeassistant/components/binary_sensor/zha.py | 3 ++- homeassistant/components/zha/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/binary_sensor/zha.py b/homeassistant/components/binary_sensor/zha.py index 756323f41d9..be61a9e9ba4 100644 --- a/homeassistant/components/binary_sensor/zha.py +++ b/homeassistant/components/binary_sensor/zha.py @@ -133,7 +133,8 @@ class BinarySensor(zha.Entity, BinarySensorDevice): from bellows.types.basic import uint16_t result = await zha.safe_read(self._endpoint.ias_zone, - ['zone_status']) + ['zone_status'], + allow_cache=False) state = result.get('zone_status', self._state) if isinstance(state, (int, uint16_t)): self._state = result.get('zone_status', self._state) & 3 diff --git a/homeassistant/components/zha/__init__.py b/homeassistant/components/zha/__init__.py index 9d7556fc334..d293d4d07cd 100644 --- a/homeassistant/components/zha/__init__.py +++ b/homeassistant/components/zha/__init__.py @@ -410,7 +410,7 @@ def get_discovery_info(hass, discovery_info): return all_discovery_info.get(discovery_key, None) -async def safe_read(cluster, attributes): +async def safe_read(cluster, attributes, allow_cache=True): """Swallow all exceptions from network read. If we throw during initialization, setup fails. Rather have an entity that @@ -420,7 +420,7 @@ async def safe_read(cluster, attributes): try: result, _ = await cluster.read_attributes( attributes, - allow_cache=True, + allow_cache=allow_cache, ) return result except Exception: # pylint: disable=broad-except