Plugin problem with 120 seconds onheartbeat period Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
febalci
Posts: 331
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Plugin problem with 120 seconds onheartbeat period

Post 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??
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Plugin problem with 120 seconds onheartbeat period

Post 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.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
febalci
Posts: 331
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Plugin problem with 120 seconds onheartbeat period

Post by febalci »

Exactly what i was looking for... Thanks a lot...
merlot
Posts: 33
Joined: Saturday 13 April 2019 16:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Plugin problem with 120 seconds onheartbeat period

Post 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
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Plugin problem with 120 seconds onheartbeat period

Post by Dnpwwo »

@merlot,

Have a look at https://github.com/dnpwwo/Domoticz-GlobalCache-Plugin and search for 'lastPolled'
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
merlot
Posts: 33
Joined: Saturday 13 April 2019 16:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Plugin problem with 120 seconds onheartbeat period

Post 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
Post Reply