parent
c2dc940819
commit
b857f838df
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue