Skip to content

Commit

Permalink
fix (sensor): add checks for timer values
Browse files Browse the repository at this point in the history
Closes #501
  • Loading branch information
alandtse committed Jan 2, 2020
1 parent 51a29ff commit ead4cb2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions custom_components/alexa_media/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,19 @@ def _fix_alarm_date_time(self, value):
return value
naive_time = dt.parse_datetime(value[1][self._sensor_property])
timezone = pytz.timezone(self._client._timezone)
if timezone:
if timezone and naive_time:
value[1][self._sensor_property] = timezone.localize(naive_time)
else:
_LOGGER.warning(
"%s does not have a timezone set. "
"%s is returning erroneous data."
"Returned times may be wrong. "
"Please set the timezone in the Alexa app.",
"Please confirm the timezone in the Alexa app is correct. "
"Debugging info: \nRaw: %s \nNaive Time: %s "
"\nTimezone: %s",
self._client.name,
value[1],
naive_time,
self._client._timezone,
)
return value

Expand Down

0 comments on commit ead4cb2

Please sign in to comment.