mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
parent
c2dc940819
commit
b857f838df
@ -116,14 +116,20 @@ class BroadlinkData(object):
|
|||||||
|
|
||||||
def _update(self, retry=2):
|
def _update(self, retry=2):
|
||||||
try:
|
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:
|
except socket.timeout as error:
|
||||||
if retry < 1:
|
if retry < 1:
|
||||||
_LOGGER.error(error)
|
_LOGGER.error(error)
|
||||||
return
|
return
|
||||||
if not self._auth():
|
if retry < 1 or not self._auth():
|
||||||
return
|
return
|
||||||
return self._update(max(0, retry-1))
|
self._update(retry-1)
|
||||||
|
|
||||||
def _auth(self, retry=2):
|
def _auth(self, retry=2):
|
||||||
try:
|
try:
|
||||||
@ -131,5 +137,5 @@ class BroadlinkData(object):
|
|||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
auth = False
|
auth = False
|
||||||
if not auth and retry > 0:
|
if not auth and retry > 0:
|
||||||
return self._auth(max(0, retry-1))
|
return self._auth(retry-1)
|
||||||
return auth
|
return auth
|
||||||
|
Loading…
x
Reference in New Issue
Block a user