Page 1 of 1

SOLVED: Does heartbeat takes into acount execution time?

Posted: Saturday 28 December 2024 10:18
by averter
Hello,

I am wondering if when using the `heartbeat` function in the domoticz module (see https://wiki.domoticz.com/Developing_a_ ... llable_API) inside of a loop, takes into account the execution time of the code between consecutive iterations? In essence, I am wondering if heartbeat can be considered equivalent to this type of solution https://stackoverflow.com/questions/725 ... s#72587779 where timing of the execution is critical/accounted for. Thanks.

Re: Does heartbeat takes into acount execution time?

Posted: Saturday 28 December 2024 15:15
by gizmocuz
No, it should be executed at every heartbeat interval

But I guess you want to use a timer? You can create your own timers in Python if you want
Or you can set the timer parameters in dzVents scripts

Re: Does heartbeat takes into acount execution time?

Posted: Saturday 28 December 2024 16:42
by averter
Thanks for your reply.
The main objective is to read values from an inverter at specific intervals, and I'm using this plugin to do so https://github.com/saidlm/Domoticz-Sola ... 8C8-L251C1

As you can see, the author has used heartbeat to pause between consecutive iterations, and that's why I was wondering if the code could be improved (apparently yes). Thanks again for your help.

Re: SOLVED: Does heartbeat takes into acount execution time?

Posted: Saturday 28 December 2024 18:04
by waltervl
Why do you want it to be so specific that it needs a more precise timer? Is for example every approx 30 seconds not good enough? What goes wrong if it is sometimes 29 or 31 seconds?

Re: SOLVED: Does heartbeat takes into acount execution time?

Posted: Sunday 29 December 2024 8:01
by averter
waltervl wrote: Saturday 28 December 2024 18:04 Why do you want it to be so specific that it needs a more precise timer? Is for example every approx 30 seconds not good enough? What goes wrong if it is sometimes 29 or 31 seconds?
The reason is that I'm using a smart EV charger (dombusevse) along with the inverter, and for it to adjust the charging load properly domoticz should have readings from the inverter at every 5-6 seconds. The more precisely the better (less fluctuations).

Although 5-6 seconds might seem exaggerated, according to the dombusevse's website this is a standard value:
The 6s time (SAE1772 standard) corresponds with the max time that the OBC can use to modify the consumed power in accordance with what is established by the EVSE module

Re: SOLVED: Does heartbeat takes into acount execution time?

Posted: Sunday 29 December 2024 13:59
by waltervl
Every 5 or 6 seconds should be handled correctly unless you have a lot running on your system including mqtt.
Execution times of scripts should not exceed a couple of seconds. If not you have programmed the scripts incorrectly. For dzvents scripts look at asynchronous external commands execution, incl openURL().