Closed bnordli closed 3 years ago
Interesting, mine just did the same thing. I guess it might be a conflict with winter/summer time or such.
It's a little strange, because Swedish/Norwegian summer time is UTC+2 while winter time is UTC+1, so UTC+3 seems like a bug in the Plejd software.
This line fixes the problem for me, at least during summer hours:
n = n + timedelta(minutes=60)
I guess we have to wait some months to see what the Plejd system does during winter time, but I think a config setting (minutes_offset) would be handy for those not wanting to change the code.
So for me the current code worked during winter, and now it logs:
2021-06-09 08:06:34 DEBUG (MainThread) [custom_components.plejd.light] Plejd network reports time as '2021-06-09 09:06:33'
2021-06-09 08:06:34 INFO (MainThread) [custom_components.plejd.light] Plejd time delta is 3601 seconds, setting time to '2021-06-09 10:06:34.199084'.
An interesting difference is that my system time runs on UTC, but the offset from plejd time is what's interesting I guess. For me plejd ran on local time during winter, and now 1h after apparently. I'll look into this a bit and try to think of something that doesn't require more settings.. :)
FYI: After the time zone switch, I didn't need to to anything (!). My Plejd system is still reporting time to be 60 minutes off.
Interesting (annoying?).
My system changes to now not be offset at all from swedish winter time. I wonder if it's worth keeping the time code around at all if it's this inconsistent, it's not really needed for anything when you connect it with home assistant anyways.
(It's not annoying to me, as I can keep the offset at +60 mins throughout the year.) I would like to keep the time syncing feature, possibly making it optional.
Rationale: I use Plejd's time feature to trigger scenarios, and it is very handy that HA makes sure its time is correct. Yes, with #54, I can also trigger Plejd scenarios from HA, but I guess some people still want to use Plejd to setup astro/time triggers.
Fair enough.. it doesn't disturb me at all that it gets my time wrong half the year since I don't use the app or time at all.
After connecting this component to my Plejd system, I noticed that the time functions started to behave strangely. I added debug logging and saw this:
After reconnecting with the app, it resynchronizes the devices and the component logs the following. (I have removed the message details.)
..and then of course the component reports again:
I am at UTC+2, but it looks like Plejd is reporting time in UTC +3 (!). The timers from my app worked correctly before I attached Home Assistant, so at least it is internally consistent.
Suggested solution: If possible, read the time zone information from Plejd, otherwise add a time zone (or offset) setting to the component to avoid setting the wrong clock.