My automations with set time triggers always trigger later than requested

Mentioned back here, but there is a lot of info in this thread now.

It is a very simple 2 host cluster;
Hypervisor:VMware ESXi, 7.0.3, 19482537
Model:NUC11PAHi7

No shared storage currently. Identical hardware and esx versions.
Migrations between hosts are always compute and datastore, so it’s either all on one or the other host.
No difference in network configuration.

Home Assistant Core 2022.5.5
Home Assistant Supervisor 2022.05.2
Home Assistant OS 8.0
Kernel version 5.15.38
Agent version 1.2.1

1 Like

A host cluster?
So how much is shared between the two?
Memory, USB devices or…

2 node* cluster.

No resource sharing between the two.
Each have 64GB DDR3200, 512GB 970 Pro nvme.

Passthrough conbee II from 1 host to 1vm, but hasn’t been enabled for vMotion. When I moved HA back to the other host I just moved the stick :).

All my automations yesterday triggered correctly down to the second.
I will move the VM back to the ?bad? host today and see if the problem reoccurs.

Also - I have Debian, Centos, W11, Server 2019 all moving between these hosts running various things with no issues.

I came here because I’m also having trouble with my automations triggering at odd times.

Here’s a dead simple 6pm automation, running 2 minutes late: It does indeed appear to be running 2 minutes later than 6pm, when I confirm against my iPhone time and wall clocks.

I checked the suggested test templates and they returned my expected local time and timezone

The “date” command in the terminal also returns the expected local time.

Any other diagnostic tools I can run?

I am running in a Hyper-V VM on Windows. Tried backup/restore to a whole new server and problem persists.

When you run in a VM you will by default not have access to a high precision realtime clock (RTC), due to the hardware abstraction layer the hypervisor have inserted between the VM and the actual hardware.
Some hypervisors have an integration package that can be installed on common guest OSes to provide the RTC feature.
Other solutions is to get an USB RTC and connect that directly to the VM.

I too am seeing the same behavior and I am not using a VM. In my case, I am using virtualenv installation of HA core (2022.11.5) on Xubuntu 22.04 on an intel celeron N3350 machine.

Automations using a time based trigger are triggering approx 3 minutes late.

Example:

Unsure how long this issue has been occurring. I only became aware of it after having recently enabled my holiday lighting routines and noticing they were triggering just a little late.

I confirmed that the home assistant machine local time is correct by verifying with {{now()}} in template console and via ‘date’ in terminal.

HA log shows no unusual lines associated with the automation triggers.

Going to experiment by adding a few seconds to the trigger time (e.g. at: ‘06:30:01’ ) to see if the behavior changes.

1 Like

I have the exact same issue

1 Like

I have the same problem
My HS is running in a virtual machine on proxmox.
I used to run these automations on NodeRed and did not have this problem.

I REINSTALLED the whole damn thing using the official instructions and OS recommended and I still have issues with it

Version 2023.1.7

I have seen several of these issues posted on the forum and they are all related to hypervisor software.
My guess is that without the proper hypervisor guest integration install in the guest OS the time will slide a bit.

Even following official instructions?

It’s driving me completely nuts. This issue should be higher priority imo. “time” is a pretty basic integration and is failing to work properly.

Make a search for “Clock skew” on google.

This makes sense. I think that the gazilion of docker containers drift apart in time, but this should not happen. Should be as simple as requesting NTP time to the host machine to sync.

On a bare bone system the hardware keeps a pretty precise clock frequency, but on a hypervisor that clock is emulated and the resources to keep it updated is shared with the host OS.

Strange thing that I just noticed is that other automations do trigger EXACTLY on time. Only some do not…

Specific times of day or do the automations use certain resources?
If the time is specific, then it can be related to when the ntp pulls are done, because these will correct any time skew at that point in time.
If it is a resource, then it can be delays in access to these that cause it.

I have the exact same problem. I have checked what was suggested above.
My setup is a docker VM on an ESXI host.

I logged into each and all times match – ESXI host, ubuntu VM, and the docker container all match. I have setup manual NTP syncs.

Also tried mounting the ubuntu VM’s time into the container:

    - "/etc/timezone:/etc/timezone:ro"
    - "/etc/localtime:/etc/localtime:ro"

I will add it is not just the automations set to an exact time- it is also the sunset/sunrise time based triggers that have the same problem

Has anyone found the source of the problem? It is so odd that the times are seemingly random and not off by a set value each day.

I had a telegram alert sent for each time the automation is triggered and the correct time was reported. Basically a copy of what was noted above on template editor

Maybe it is actually running on the correct time, but the logging is delayed in the database.
HA does not log the time the event happened, but the time it was written to the database.

It does not trigger the automation at the correct time. I don’t think the logging is the issue. My lights at specific time in AM and the PM lights that are based on sunset time are both off by 120 +/ 20ish minutes - similar to everyone above

edit: actually the time difference is always 2 hours, 23 minutes +/- 2 seconds - this is the same for various automations i have that go off at 10pm, 11pm, and a few hours earlier based on sunset time

I have found a reliable workaround that does not require to change any existing automations!

By coincidence I found out that if you add a entity that changes every second, it somehow makes ALL automations to trigger ON TIME. This can be a dummy sensor.

Just add following and you should be golden:

# Add a dummy entity that updates every second
template:
  - trigger:
      - platform: time_pattern
        seconds: "/1"
    sensor:
      - name: timestamp
        state: "{{ now().timestamp() }}"

# Exclude above entity from recorder
# to avoid filling up the database with useless info
recorder:
  exclude:
    entities:
      - sensor.timestamp
2 Likes