mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Check for error and pull obvservation
This commit is contained in:
parent
87f81bf3b4
commit
4e586c18ff
@ -153,9 +153,11 @@ class WUndergroundData(object):
|
|||||||
"""Get the latest data from wunderground."""
|
"""Get the latest data from wunderground."""
|
||||||
try:
|
try:
|
||||||
result = requests.get(self._build_url(), timeout=10).json()
|
result = requests.get(self._build_url(), timeout=10).json()
|
||||||
|
if "error" in result['response']:
|
||||||
|
raise ValueError(result['response']["error"]
|
||||||
["description"])
|
["description"])
|
||||||
else:
|
else:
|
||||||
self.data = result.json()["current_observation"]
|
self.data = result["current_observation"]
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
_LOGGER.error("Check Wunderground API %s", err.args)
|
_LOGGER.error("Check Wunderground API %s", err.args)
|
||||||
self.data = None
|
self.data = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user