mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Catch request exceptions and log a warning
This commit is contained in:
parent
b3b2f2e326
commit
16a3511c0a
@ -8,7 +8,7 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.efergy.html
|
||||
"""
|
||||
import logging
|
||||
from requests import get
|
||||
from requests import get, RequestException
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
@ -80,6 +80,7 @@ class EfergySensor(Entity):
|
||||
|
||||
def update(self):
|
||||
""" Gets the Efergy monitor data from the web service. """
|
||||
try:
|
||||
if self.type == 'instant_readings':
|
||||
url_string = _RESOURCE + 'getInstant?token=' + self.app_token
|
||||
response = get(url_string)
|
||||
@ -96,3 +97,5 @@ class EfergySensor(Entity):
|
||||
self._state = response.json()['sum']
|
||||
else:
|
||||
self._state = 'Unknown'
|
||||
except RequestException:
|
||||
_LOGGER.warning('Could not update status for %s', self.name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user