Cereal2nd / velbus-aio

Velbus Asyncio
Apache License 2.0
15 stars 10 forks source link

Feature Request: Automatic time sync with home assistant clock #42

Closed darkpainy closed 2 years ago

darkpainy commented 2 years ago

Hi,

I've noticed after powerfailure that Velbus clock is reset. I now manually sync the clock via HA. Although I could write an automation that syncs the clock at boot time it would be beter if the velbus integration notices an offset it automaticaly syncs the clock. This would fix multiple clock issues at once:

How i imagine this would work, since the velbus clock of each module is pushed on the bus every once in a while, the integration could pick up on each of these messages and compare them to it's own linux clock. if the offset is greater than, for example 5 seconds, it could force a clock sync to all or that specific module (don't know if one module sync is possible).

Thanks in advance!

Kind regards, Jeroen

Cereal2nd commented 2 years ago

this is a great idea and should be easy to implement. but this should be behind a config option.

90% is there we just need to check for an incomming time message and parse it

darkpainy commented 2 years ago

Any idea on implementation time :)?

Cereal2nd commented 2 years ago

after the festival season i can have a look. but we can only do this outside of an automation if hass generates an event once a day or something like this if hass des not generate this we can not trigger it

looking at this list there is no time based event: https://www.home-assistant.io/docs/configuration/events/

maybe we can automaticly generate the automation, but not sure if this is allowed

pguns commented 11 months ago

Any progress on this ? I also like an automatic time sync for the Velbus. Has someone already a solution ?

Thanks, Peter.

pguns commented 11 months ago

I made this automation in the meanwhile : The automation syncs the Velbus-time every day at 03:00:05 AM, so changes for the DST summer- and wintertime will be (hopefully) automatically applied next time ;-)

alias: Sync Velbus clock
description: ""
trigger:
  - platform: time
    at: "03:00:05"
condition: []
action:
  - service: velbus.sync_clock
    data:
      interface: 192.168.1.34:54934
mode: single
Cereal2nd commented 11 months ago

For what I found there is no way to automatically create an automation from within an integration.

I can add this example automation to the docu, but that's about all I can do.