Allow only_cache parameter in zha.safe_read() (#16553)

* Allow only_cache parameter in zha.safe_read()

* Use cache_only for binary_sensor.zha initial update.

* Use cache_only for fan.zha initial update.

* Use cache_only for sensor.zha initial update.

* Use cache_only for switch.zha initial update.

* Use cache_only for light.zha initial update.

* Refactor cached only read in zha platform.
This commit is contained in:
Alexei Chetroi authored and Pascal Vizeli committed 2018-09-13 09:22:50 +02:00
1 parent f2203e52ef
commit 7a52bbdf24
6 files changed
+30 -12

No files matched your search

+3 -1
View File
@@ -86,5 +86,7 @@ class Switch(zha.Entity, SwitchDevice):
async def async_update(self):
"""Retrieve latest state."""
result = await zha.safe_read(self._endpoint.on_off,
['on_off'])
['on_off'],
allow_cache=False,
only_cache=(not self._initialized))
self._state = result.get('on_off', self._state)