I tried your value_template
automation time 10:00:00 trace 10:03:30
much better, but not as quick as it should be.
I have created a new HA on an old intel pc using a generic X86-84.
added my shelly 2 lamp and one automation
automation time 11:00:00 trace 11:00:00
no delay at all. This proves there is nothing wrong (delay) with the shelly 2 device.
It does boot very quickly compared to my old mac mini.
I am now suspecting the mac mini is underpowered?
I built a new VM for HA.
added my shelly 2 lamp and one automation
automation time 12:00:00 trace 12:02:15 using value_template
Looked at the paravirtualization on the VM. This was set to Default. for Linux guests, it is recommended to use KVM. Now changed, but still about 2 minutes delay.
On my existing VM
changed the paravirtualization to KVM
automation time 16:05:00 trace 16:05:20 using value_template; much better.
The cpu load and memory usage graphs on the mac mini show about 15% cpu and 20% memory usage.
So its not working very hard, even when the automation is triggered.
The memory usage of the HA (settings->system:>hardware) show
still nothing looks like a problem.
I will test again tonight at sunset and 22:15 and report back.