HI,
using this now:
timeDifference = 2 #adapt according to the continental time differences for Summer/Winter time
and
if state:
dt = state.last_changed + datetime.timedelta(hours= timeDifference)
time = '%02d:%02d' % (dt.hour, dt.minute)
worked fine for almost a year.
I knew that for a specific period in the year, my local timezone and the python time differ only 1 hour. thought I’d adjust that if and when that happens. Never would have thought it to cause my system to go bonkers, which apparently it did today…
Had some serious mindtwists, until I saw my presence sensors being off for 1 hour and then it became clear it was that time of the year…
so, manually edited the timeDifference to be 1, and the system calmed down again.
Since I don’t want that to happen again, I was wondering if I could somehow automate the process.
for that I would need to:
- test for the local timedifference and python time
- create a sensor of some kind (preferably since I use the timeDifference in several python scripts), or, if must be, a way to calculate that difference in the python script itself.
Could be the timeDifference being Off for 2 hours is the exception, and 1 hour is normal, but that doesn’t make any difference for the logic does it. We’re +1 CET throughout the year, except for the period CET doesn’t follow daylight saving time. Now how to check that…
@petro and @pnbruckner maybe you would know how I can do that?
thanks!