Fix binary_sensor async_update (#14376)

pull/14380/head
damarco 2018-05-10 19:59:23 +02:00 committed by Russell Cloran
parent eb2671f4bb
commit 6e831138b4
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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