Skip to content
Snippets Groups Projects
Commit b857f838 authored by Daniel Høyer Iversen's avatar Daniel Høyer Iversen Committed by GitHub
Browse files

Broadlink (#6051)

* Add fail checking of broadlink data
parent c2dc9408
No related branches found
No related tags found
No related merge requests found
......@@ -116,14 +116,20 @@ class BroadlinkData(object):
def _update(self, retry=2):
try:
self.data = self._device.check_sensors_raw()
data = self._device.check_sensors_raw()
if (data.get('humidity', 0) <= 100 and
data.get('light', 0) in [0, 1, 2, 3] and
data.get('air_quality', 0) in [0, 1, 2, 3] and
data.get('noise', 0) in [0, 1, 2]):
self.data = data
return
except socket.timeout as error:
if retry < 1:
_LOGGER.error(error)
return
if not self._auth():
return
return self._update(max(0, retry-1))
if retry < 1 or not self._auth():
return
self._update(retry-1)
def _auth(self, retry=2):
try:
......@@ -131,5 +137,5 @@ class BroadlinkData(object):
except socket.timeout:
auth = False
if not auth and retry > 0:
return self._auth(max(0, retry-1))
return self._auth(retry-1)
return auth
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment