Merge pull request #1281 from molobrakos/eliqonline
improve error handling
This commit is contained in:
commit
5756cff8a4
1 file changed
+3
-2
@@ -7,6 +7,7 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/sensor.eliqonline/
|
https://home-assistant.io/components/sensor.eliqonline/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
from urllib.error import URLError
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.const import (STATE_UNKNOWN, CONF_ACCESS_TOKEN, CONF_NAME)
|
from homeassistant.const import (STATE_UNKNOWN, CONF_ACCESS_TOKEN, CONF_NAME)
|
||||||
|
|
||||||
@@ -73,5 +74,5 @@ class EliqSensor(Entity):
|
|||||||
try:
|
try:
|
||||||
response = self.api.get_data_now(channelid=self.channel_id)
|
response = self.api.get_data_now(channelid=self.channel_id)
|
||||||
self._state = int(response.power)
|
self._state = int(response.power)
|
||||||
except TypeError: # raised by eliqonline library on any HTTP error
|
except (TypeError, URLError):
|
||||||
pass
|
_LOGGER.error("could not connect to the eliqonline servers")
|
||||||
Reference in new issue
Block a user