Cereal2nd / velbus-aio

Velbus Asyncio
Apache License 2.0
14 stars 10 forks source link

sync_clock functionality doesn't use home assistant time #97

Open darkpainy opened 3 months ago

darkpainy commented 3 months ago

I have an issue where the sync clock function uses a system time of the velserv tcp server (which in my case is a docker container with the wrong time). Using velbuslink software (this uses the same TCP server as connection) I can set the correct time from the software. Could the integration somehow use the timestamp of home assistant in the sync message?

Cereal2nd commented 3 months ago

if you use the sync_clock it will use the time.localtime() from the home-assistant server. there is no interaction with the tcp server, we craft (in velbusaio) all packages in hex. so it will use th hass time.

Note: velbustcp (from velbus) also has a sync clock functionality, this one will use the time from the container/system where its running.

are you use it came from the hass sync_clock service?

darkpainy commented 3 months ago

Hey @Cereal2nd

I call the sync_clock service from HA, I just collected the logs from the velbus integration. Now, I see something is indeed wrong, but I couldn't explain it :) at 22:33, i executed the sync through HA, while velbus debug logging was enabled:

2024-04-02 20:33:27.539 DEBUG (MainThread) [velbus-protocol] TX: RawMessage(priority=fb, address=00, rtr=False, command=216, data=b'd8 01 14 21') 2024-04-02 20:33:27.601 DEBUG (MainThread) [velbus-protocol] TX: RawMessage(priority=fb, address=00, rtr=False, command=183, data=b'b7 02 04 07 e8') 2024-04-02 20:33:27.662 DEBUG (MainThread) [velbus-protocol] TX: RawMessage(priority=fb, address=00, rtr=False, command=175, data=b'af 01')

I believe that is the SYNC clock command. as you can see, in my Log the time is wrong, 20:33.

But when I check {{ now() }} in my HA, i see 22:33 2024-04-02 22:41:00.330474+02:00 (this is a couple minutes later ofc, just to show output of the "now()". So my timezone in HA is correct... Now apparently, logs and some other things take the linux host as timezone for logs etc, in my case a docker container. I added environment:

I don't know if you can use home assistant time in the sync instead of the time.localtime which is apparentaly the linux host time. Doesn't really matter as the "non-issue" is solveable, but using actual configurable HA time might be somewhat easier/nicer to have?

Anyway, sorry for the long post, the trouble and false issue rapport.

Cheers