Skip to content
This repository has been archived by the owner on Feb 13, 2022. It is now read-only.

Commit

Permalink
fixes issue #2
Browse files Browse the repository at this point in the history
Checking forecast is a string before attempting to parse, this is
due to the change for templates to pass through types instead of
always strings.
  • Loading branch information
xannor committed Nov 20, 2020
1 parent 51aca22 commit 0d2163e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions custom_components/weather_template/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,18 @@ def _updater(value):
return _updater

def _update_forecast(self, forecast):
try:
forecast_json = json.loads(forecast)
except ValueError:
_LOGGER.error(
"Could not parse forecast from template response: %s", forecast
)
self._forecast = None
return
if type(forecast) == str:
try:
forecast_json = json.loads(forecast)
except ValueError:
_LOGGER.error(
"Could not parse forecast from template response: %s", forecast
)
self._forecast = None
return
else:
forecast_json = forecast

self._forecast = forecast_json

def _add_float_template_attribute(
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "Weather Template",
"homeassistant": "0.115.0"
"homeassistant": "0.118.0"
}

0 comments on commit 0d2163e

Please sign in to comment.