Better error handling in Tibber (#18363)
* Better error handling in Tibber * return if received error
This commit is contained in:
parent
d9533127f9
commit
f0a0ce504b
3 changed files with 12 additions and 4 deletions
|
@ -171,8 +171,16 @@ class TibberSensorRT(Entity):
|
||||||
|
|
||||||
async def _async_callback(self, payload):
|
async def _async_callback(self, payload):
|
||||||
"""Handle received data."""
|
"""Handle received data."""
|
||||||
data = payload.get('data', {})
|
errors = payload.get('errors')
|
||||||
live_measurement = data.get('liveMeasurement', {})
|
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._state = live_measurement.pop('power', None)
|
||||||
self._device_state_attributes = live_measurement
|
self._device_state_attributes = live_measurement
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.const import (EVENT_HOMEASSISTANT_STOP, CONF_ACCESS_TOKEN,
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
REQUIREMENTS = ['pyTibber==0.7.4']
|
REQUIREMENTS = ['pyTibber==0.7.5']
|
||||||
|
|
||||||
DOMAIN = 'tibber'
|
DOMAIN = 'tibber'
|
||||||
|
|
||||||
|
|
|
@ -812,7 +812,7 @@ pyRFXtrx==0.23
|
||||||
pySwitchmate==0.4.3
|
pySwitchmate==0.4.3
|
||||||
|
|
||||||
# homeassistant.components.tibber
|
# homeassistant.components.tibber
|
||||||
pyTibber==0.7.4
|
pyTibber==0.7.5
|
||||||
|
|
||||||
# homeassistant.components.switch.dlink
|
# homeassistant.components.switch.dlink
|
||||||
pyW215==0.6.0
|
pyW215==0.6.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue