Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error handling in Tibber #18363

Merged
merged 2 commits into from Nov 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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')
Danielhiversen marked this conversation as resolved.
Show resolved Hide resolved
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