mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
catch exception and log
This commit is contained in:
parent
008d65677b
commit
307b2c629b
@ -86,10 +86,8 @@ class TelldusLiveData(object):
|
|||||||
|
|
||||||
def validate_session(self):
|
def validate_session(self):
|
||||||
""" Make a dummy request to see if the session is valid """
|
""" Make a dummy request to see if the session is valid """
|
||||||
try:
|
response = self.request("user/profile")
|
||||||
return 'email' in self.request("user/profile")
|
return response and 'email' in response
|
||||||
except RuntimeError:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def discover(self):
|
def discover(self):
|
||||||
""" Update states, will trigger discover """
|
""" Update states, will trigger discover """
|
||||||
@ -143,10 +141,13 @@ class TelldusLiveData(object):
|
|||||||
# re-use sessions, instead it opens a new session for each request
|
# re-use sessions, instead it opens a new session for each request
|
||||||
# this needs to be fixed
|
# this needs to be fixed
|
||||||
|
|
||||||
response = self._client.request(what, params)
|
try:
|
||||||
|
response = self._client.request(what, params)
|
||||||
_LOGGER.debug("got response %s", response)
|
_LOGGER.debug("got response %s", response)
|
||||||
return response
|
return response
|
||||||
|
except (ConnectionError, TimeoutError):
|
||||||
|
_LOGGER.error("failed to make request to Tellduslive servers")
|
||||||
|
return None
|
||||||
|
|
||||||
def update_devices(self,
|
def update_devices(self,
|
||||||
local_devices,
|
local_devices,
|
||||||
@ -172,21 +173,15 @@ class TelldusLiveData(object):
|
|||||||
|
|
||||||
def update_sensors(self):
|
def update_sensors(self):
|
||||||
""" update local list of sensors """
|
""" update local list of sensors """
|
||||||
try:
|
self._sensors = self.update_devices(self._sensors,
|
||||||
self._sensors = self.update_devices(self._sensors,
|
request_sensors(),
|
||||||
request_sensors(),
|
"sensor")
|
||||||
"sensor")
|
|
||||||
except OSError:
|
|
||||||
_LOGGER.warning("could not update sensors")
|
|
||||||
|
|
||||||
def update_switches(self):
|
def update_switches(self):
|
||||||
""" update local list of switches """
|
""" update local list of switches """
|
||||||
try:
|
self._switches = self.update_devices(self._switches,
|
||||||
self._switches = self.update_devices(self._switches,
|
request_switches(),
|
||||||
request_switches(),
|
"switch")
|
||||||
"switch")
|
|
||||||
except OSError:
|
|
||||||
_LOGGER.warning("could not update switches")
|
|
||||||
|
|
||||||
def _check_request(self, what, **params):
|
def _check_request(self, what, **params):
|
||||||
""" Make request, check result if successful """
|
""" Make request, check result if successful """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user