Hi,
Seems just as of yesterday that I had a bug. But it might very well be there for a very long time.
I noticed that, when restarting HA yesterday, calendars didn’t appear. In the log I get an error about the timezone : " ERROR (SyncWorker_2) [root] ‘Romance Standard Time’" and then it complains not being able to compare events : " TypeError: can’t compare offset-naive and offset-aware datetimes".
The line where error occurs is in the caldav/calendar.py in the update function, it’s a problem when it tries to sort the current day’s events.
# dtstart can be a date or datetime depending if the event lasts a # whole day. Convert everything to datetime to be able to sort it results.sort(key=lambda x: self.to_datetime( x.instance.vevent.dtstart.value ))
I looked at the events, I tried to run step by step and I discovered that there’s a problem when the timezone is “Romance Standard Time”, instead of “CET”. I don’t know which client does set that but still, seems to be valid as no client I use is complaining (Outlook, Thunderbird, Android apps…)
I found a workaround in the “to_datetime” function that is used to compare the dates. It checks if the object is already a datetime, if so doesn’t change anything. I just removed the test and it goes well, I just still have the initial error about Romance Standard time, but calendars load and everything seems fine !
def to_datetime(obj):
"""Return a datetime."""
#if isinstance(obj, datetime):
#return obj
return dt.as_local(dt.dt.datetime.combine(obj, dt.dt.time.min))
Question is : is this a bug in the component (in which case there must be a better workaround) or is my OS unable to handle this timezone ? Running Ubuntu 18.04 LTS, HA in a virtenv, python 3.6.2.