Page 1 of 1

Plugin problem with 120 seconds onheartbeat period

Posted: Wednesday 15 November 2017 11:16
by febalci
Hi all,
In a python plugin that i wrote, When i set a heartbeat period of greater than 60 seconds, the plugin gives "Error: hardware (2) thread seems to have ended unexpectedly". Below, i set the heartbeat to 90 seconds:

Code: Select all

2017-11-15 13:04:31.865 (fg) Initialized version 1.0.0, author 'febalci'
2017-11-15 13:04:41.440 (fg) Calling message handler 'onHeartbeat'.
2017-11-15 13:04:41.440 (fg) onHeartbeat called 
2017-11-15 13:06:00.904 Error: fg hardware (2) thread seems to have ended unexpectedly
2017-11-15 13:06:11.895 (fg) Calling message handler 'onHeartbeat'.
2017-11-15 13:06:11.895 (fg) onHeartbeat called 
2017-11-15 13:07:30.429 Error: fg hardware (2) thread seems to have ended unexpectedly
2017-11-15 13:07:42.440 (fg) Calling message handler 'onHeartbeat'.
2017-11-15 13:07:42.440 (fg) onHeartbeat called 
2017-11-15 13:09:00.883 Error: fg hardware (2) thread seems to have ended unexpectedly
2017-11-15 13:09:12.909 (fg) Calling message handler 'onHeartbeat'.
2017-11-15 13:09:12.909 (fg) onHeartbeat called 
Although the error messages show up, the plugin continues to work. Please note that the errors exist start of the minute plus the heartbeat period like minutes: 06:00, 07:30, 09:00 etc. But the heartbeat period starts with the plugin onstart. How can i get rid of the error messages??

Re: Plugin problem with 120 seconds onheartbeat period

Posted: Thursday 16 November 2017 1:49
by Dnpwwo
@febalci,

You are not the first person to be confused by this so I have updated the wiki page to cover it here:
http://www.domoticz.com/wiki/Developing ... #Callbacks
Warning: Setting this interval to greater than 30 seconds will cause a 'thread seems to have ended unexpectedly' message to be written to the log file every 30 seconds. The plugin will function correctly but this message can not be suppressed because it is a standard warning from Domoticz that a piece of hardware may have stopped responding.
If a plugin wants to heartbeat every 100 seconds it should be coded with the heartbeat interval set to 10, 20 or 25 seconds and only take action every 6th, 5th or 4th time the callback is invoked.

Re: Plugin problem with 120 seconds onheartbeat period

Posted: Thursday 16 November 2017 13:37
by febalci
Exactly what i was looking for... Thanks a lot...

Re: Plugin problem with 120 seconds onheartbeat period

Posted: Monday 15 July 2019 23:46
by merlot
Hello,
Would you be so kind to show me how you have avoid this annoying error? How do yo update information every 4 callbacks?
Thank you very much

Re: Plugin problem with 120 seconds onheartbeat period

Posted: Tuesday 16 July 2019 0:18
by Dnpwwo
@merlot,

Have a look at https://github.com/dnpwwo/Domoticz-GlobalCache-Plugin and search for 'lastPolled'

Re: Plugin problem with 120 seconds onheartbeat period

Posted: Thursday 18 July 2019 19:24
by merlot
Dnpwwo wrote: Tuesday 16 July 2019 0:18 @merlot,

Have a look at https://github.com/dnpwwo/Domoticz-GlobalCache-Plugin and search for 'lastPolled'
I've got it, thank's a lot