Updates pyatmo to 1.8 and adds exception handling (#20938)
* switch to pyatmo 1.7 & add exception handling * STATE_UNKNOWN => None * correct too long line * delete whitespace * remove fancy update logic
This commit is contained in:
parent
5dfaec5967
commit
1e69848af4
3 changed files with 156 additions and 146 deletions
|
@ -16,7 +16,7 @@ from homeassistant.helpers import discovery
|
|||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
REQUIREMENTS = ['pyatmo==1.4']
|
||||
REQUIREMENTS = ['pyatmo==1.8']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ class NetAtmoSensor(Entity):
|
|||
self._state = None
|
||||
return
|
||||
|
||||
try:
|
||||
if self.type == 'temperature':
|
||||
self._state = round(data['Temperature'], 1)
|
||||
elif self.type == 'humidity':
|
||||
|
@ -304,6 +305,11 @@ class NetAtmoSensor(Entity):
|
|||
self._state = "High"
|
||||
elif data['wifi_status'] <= 55:
|
||||
self._state = "Full"
|
||||
except KeyError:
|
||||
_LOGGER.error("No %s data found for %s", self.type,
|
||||
self.module_name)
|
||||
self._state = None
|
||||
return
|
||||
|
||||
|
||||
class NetAtmoData:
|
||||
|
@ -360,10 +366,14 @@ class NetAtmoData:
|
|||
self.data = self.station_data.lastData(exclude=3600)
|
||||
|
||||
newinterval = 0
|
||||
try:
|
||||
for module in self.data:
|
||||
if 'When' in self.data[module]:
|
||||
newinterval = self.data[module]['When']
|
||||
break
|
||||
except TypeError:
|
||||
_LOGGER.error("No modules found!")
|
||||
|
||||
if newinterval:
|
||||
# Try and estimate when fresh data will be available
|
||||
newinterval += NETATMO_UPDATE_INTERVAL - time()
|
||||
|
|
|
@ -930,7 +930,7 @@ pyalarmdotcom==0.3.2
|
|||
pyarlo==0.2.3
|
||||
|
||||
# homeassistant.components.netatmo
|
||||
pyatmo==1.4
|
||||
pyatmo==1.8
|
||||
|
||||
# homeassistant.components.apple_tv
|
||||
pyatv==0.3.12
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue