Stability issue

Python and python framework

Moderator: leecollings

Post Reply
ubee
Posts: 66
Joined: Tuesday 10 February 2015 20:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Sweden
Contact:

Stability issue

Post by ubee »

I have developed my own plugin for a UniPi interface board. A few days ago I started to use this as an integrated part of a heat control system, i.e. I use Domoticz to read temperature sensors and I control valves with the relays on the UniPI module.

In general it works fine but in 48h Domoticz has crashed and I found the follwing in the Domoticz log file:

2017-02-20 07:03:11.649 (UX) Calling message handler 'onCommand'.
2017-02-20 07:03:11.649 (UX) onCommand called for Unit 3: Parameter 'Off', Level: 0
2017-02-20 07:03:11.671 Error: Domoticz received fatal signal 11 !...
2017-02-20 07:03:11.679 Error: /home/pi/domoticz/domoticz() [0x1aceb4]
2017-02-20 07:03:11.679 Error: /home/pi/domoticz/domoticz(_Z14signal_handleri+0x58) [0x1acf6c]
2017-02-20 07:03:11.680 Error: /lib/arm-linux-gnueabihf/libc.so.6(__default_sa_restorer_v2+0) [0x76abe180]

It is quite clear the failure is triggered by a call to onCommand. I have a feeling this is connected to the plugin-system more than the plugin. Or potentially Domoticz....

I have no clue how to pin-point this problem. Unfortunately I didn't check the log file the first time this happened, but I will keep my eyes open now...

An update: This problem occurs frequently now. Domoticz crashes with the same error within a few minutes from starting up. I haven't changed anything in the plugin for a week or so. So why does this problem show up now????
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: Stability issue

Post by Dnpwwo »

@ubee,

Might be useful to post the contents of the 'onCommand' function. From memory your onCommand does a lot of work creating sockets as well as sending and receiving responses.

I run 6 plugins and Domoticz ran for over 2000 minutes of CPU time on a RaspberryPi (well over a week) before I forced a restart to pick up a new version so it may be something your plugin is doing or maybe one of the imports you use.
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
ubee
Posts: 66
Joined: Tuesday 10 February 2015 20:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Sweden
Contact:

Re: Stability issue

Post by ubee »

It's really strange. I put in a few Domoticz.log calls and now it seems to be stable again. Before that (this morning) I could hardly get Domoticz up an running before it failed.

My onCommand is really simple:

Code: Select all

def onCommand(Unit, Command, Level, Hue):
    
   
    Domoticz.Log("onCommand called for Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))

    Command = Command.strip()
 #   action, sep, params = Command.partition(' ')
 #   action = action.capitalize()
	

#
#   8 first units are relays that can be toggled
#
    if Unit in range(1,9):
        if (Command == 'On'):
            RelaySet(Unit,1)
            UpdateDevice(Unit,1,'On')

        elif (Command == 'Off'):
            RelaySet(Unit,0)
            UpdateDevice(Unit,0,'Off')	
 

    return True
And RelaySet and UpdateDevice is like this:

Code: Select all

def UpdateDevice(Unit, nValue, sValue):
 
# Make sure that the Domoticz device still exists (they can be deleted) before updating it
    Domoticz.Debug("Update unit no: "+str(Unit)+" value: "+ str(nValue)+" "+ str(sValue))
    if (Unit in Devices):
        if (Devices[Unit].nValue != nValue) or (Devices[Unit].sValue != sValue):
            Devices[Unit].Update(nValue, str(sValue))
            Domoticz.Log("Update "+str(nValue)+":'"+str(sValue)+"' ("+Devices[Unit].Name+")")
    return


#   
#   Control the relay indexed by Unit.
#       nValue = 0  Relay off
#       nValue = 1  Relay on
#    
def RelaySet(Unit,nValue):
    Domoticz.Debug("Relay no: "+str(Unit)+" value: "+ str(nValue))
    response = urlopen("http://"+ UNIPI_URL+"/rest/relay/"+str(Unit),bytes(urlencode({'value': str(nValue)}),'utf-8')).read()
    return
Edit: After I added the Domotics.Debug calls in the UpdateDevice and RelaySet function, the system is stable! My code is very simple. The urlopen function call is the only thing that actually do anything. This call reads/sets devices on a local I2C bus through a REST interface provided by UniPi Technology. The I2C control is implemented by a separate server daemon, so context switching will happen. But the call is synchronous anyway.

Edit2: Now 24 hours later still stable with no faults. Debug still enabled. I will disable debug logging now and see if the problem pops up again.

Edit 3: Still stable as a rock. I just can't figure out what caused the problem 2 days ago when the Domoticz server crashed frequently....
ubee
Posts: 66
Joined: Tuesday 10 February 2015 20:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Sweden
Contact:

Re: Stability issue

Post by ubee »

I make a new post so it is clear I've made a few updates on this. See my previous (edited) posting.
Informatyk
Posts: 1
Joined: Saturday 04 March 2017 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Stability issue

Post by Informatyk »

Ubee Hello, I tried to contact you to unipi.technology forum but without effect. Is it possible you shared your script - "True" Domoticz support for UNIPI?
ubee
Posts: 66
Joined: Tuesday 10 February 2015 20:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Sweden
Contact:

Re: Stability issue

Post by ubee »

Sorry, I missed your post/comment. You can find my UniPi plugin here https://www.domoticz.com/forum/viewtopi ... 67#p122345
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest