Skip to content

Commit

Permalink
Better error handling in Tibber (#18363)
Browse files Browse the repository at this point in the history
* Better error handling in Tibber

* return if received error
  • Loading branch information
Danielhiversen committed Nov 11, 2018
1 parent d953312 commit f0a0ce5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions homeassistant/components/sensor/tibber.py
Expand Up @@ -171,8 +171,16 @@ async def async_added_to_hass(self):

async def _async_callback(self, payload):
"""Handle received data."""
data = payload.get('data', {})
live_measurement = data.get('liveMeasurement', {})
errors = payload.get('errors')
if errors:
_LOGGER.error(errors[0])
return
data = payload.get('data')
if data is None:
return
live_measurement = data.get('liveMeasurement')
if live_measurement is None:
return
self._state = live_measurement.pop('power', None)
self._device_state_attributes = live_measurement
self.async_schedule_update_ha_state()
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tibber/__init__.py
Expand Up @@ -16,7 +16,7 @@
from homeassistant.helpers import discovery
from homeassistant.helpers.aiohttp_client import async_get_clientsession

REQUIREMENTS = ['pyTibber==0.7.4']
REQUIREMENTS = ['pyTibber==0.7.5']

DOMAIN = 'tibber'

Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Expand Up @@ -812,7 +812,7 @@ pyRFXtrx==0.23
pySwitchmate==0.4.3

# homeassistant.components.tibber
pyTibber==0.7.4
pyTibber==0.7.5

# homeassistant.components.switch.dlink
pyW215==0.6.0
Expand Down

0 comments on commit f0a0ce5

Please sign in to comment.