improve error handling

This commit is contained in:
Erik 2016-02-16 18:12:52 +01:00
parent 1d7aea7120
commit 44a39636b1

View File

@ -7,6 +7,7 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.eliqonline/
"""
import logging
from urllib.error import URLError
from homeassistant.helpers.entity import Entity
from homeassistant.const import (STATE_UNKNOWN, CONF_ACCESS_TOKEN, CONF_NAME)
@ -73,5 +74,5 @@ class EliqSensor(Entity):
try:
response = self.api.get_data_now(channelid=self.channel_id)
self._state = int(response.power)
except TypeError: # raised by eliqonline library on any HTTP error
pass
except (TypeError, URLError):
_LOGGER.error("could not connect to the eliqonline servers")