From 84b4c61a36710bff6bb38cfe12416995f441ee10 Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Tue, 14 Jan 2020 22:50:55 -0800 Subject: [PATCH] fix(sensor): check for AttributeError timezone Closes #501 --- custom_components/alexa_media/sensor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/alexa_media/sensor.py b/custom_components/alexa_media/sensor.py index 897397ef..ecbaa18e 100644 --- a/custom_components/alexa_media/sensor.py +++ b/custom_components/alexa_media/sensor.py @@ -178,7 +178,11 @@ def __init__( def _fix_alarm_date_time(self, value): import pytz - if self._sensor_property != "date_time" or not value: + if ( + self._sensor_property != "date_time" + or not value + or isinstance(value[1][self._sensor_property], datetime.datetime) + ): return value naive_time = dt.parse_datetime(value[1][self._sensor_property]) timezone = pytz.timezone(self._client._timezone)