Python Frame work error

Python and python framework

Moderator: leecollings

Post Reply
pipiche
Posts: 2034
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Python Frame work error

Post by pipiche »

I have some kind of corruption that I'm not able to find.

If I look the DeviceStatus table for the corresponding Python Plugin I saw 30 Devices ID from 1 to 30
When I start the plugin and I try to dump the Device dict, there are only 9 devices loaded.

Even more interesting, if I run the following code just on the 1st line of the onStart() call back

Code: Select all

    Domoticz.Log( "Device count: " + str(len(Devices)))
    for x in Devices:
        Domoticz.Log( "Device:           " + str(x) + " - " + str(Devices[x]))
I got indeed a lenght of 9, but it crash when trying to index the 9th, and there are 30 devices into Domoticz !
Mar 25 20:39:21 rasp domoticz[18462]: 2021-03-25 20:39:21.322 Python Plugin System: (DIN-ZIGate) Device count: 9
Mar 25 20:39:21 rasp domoticz[18462]: 2021-03-25 20:39:21.322 Python Plugin System: (DIN-ZIGate) Device: 1 - ID: 2, Name: 'DIN-ZIGate - Zigate Status 2', nValue: 0, sValue: 'Startup'
Mar 25 20:39:21 rasp domoticz[18462]: 2021-03-25 20:39:21.322 Python Plugin System: (DIN-ZIGate) Device: 2 - ID: 1, Name: 'DIN-ZIGate - Zigate Notifications 2', nValue: 0, sValue: 'Zigate Channel: 11'
Mar 25 20:39:21 rasp domoticz[18462]: 2021-03-25 20:39:21.323 Python Plugin System: (DIN-ZIGate) Device: 3 - ID: 3, Name: 'DIN-ZIGate - EH-ZB-VACT_Temp-00124b000425e9ad-0b', nValue: 25, sValue: '25.5'
Mar 25 20:39:21 rasp domoticz[18462]: 2021-03-25 20:39:21.323 Python Plugin System: (DIN-ZIGate) Device: 4 - ID: 4, Name: 'DIN-ZIGate - EH-ZB-VACT_ThermoSetpoint-00124b000425e9ad-0b', nValue: 0, sValue: '18.00'
Mar 25 20:39:21 rasp domoticz[18462]: 2021-03-25 20:39:21.323 Python Plugin System: (DIN-ZIGate) Device: 5 - ID: 5, Name: 'DIN-ZIGate - EH-ZB-VACT_Door-00124b000425e9ad-0b', nValue: 0, sValue: 'Closed'
Mar 25 20:39:21 rasp domoticz[18462]: 2021-03-25 20:39:21.323 Python Plugin System: (DIN-ZIGate) Device: 6 - ID: 6, Name: 'DIN-ZIGate - EH-ZB-VACT_Valve-00124b000425e9ad-0b', nValue: 0, sValue: '0.0'
Mar 25 20:39:21 rasp domoticz[18462]: 2021-03-25 20:39:21.323 Python Plugin System: (DIN-ZIGate) Device: 7 - ID: 7, Name: 'DIN-ZIGate - SP 120_Plug-00158d0001fe57bb-01', nValue: 1, sValue: 'On'
Mar 25 20:39:21 rasp domoticz[18462]: 2021-03-25 20:39:21.323 Python Plugin System: (DIN-ZIGate) Device: 8 - ID: 8, Name: 'DIN-ZIGate - SP 120_Power-00158d0001fe57bb-01', nValue: 3, sValue: '3'
Mar 25 20:39:21 rasp domoticz[18462]: File "/var/lib/domoticz/plugins/Domoticz-Zigate/plugin.py", line 1052 in DumpConfigToLog
Mar 25 20:39:21 rasp domoticz[18462]: File "/var/lib/domoticz/plugins/Domoticz-Zigate/plugin.py", line 227 in onStart
Mar 25 20:39:21 rasp domoticz[18462]: File "/var/lib/domoticz/plugins/Domoticz-Zigate/plugin.py", line 1015 in onStart
Mar 25 20:39:21 rasp domoticz[18462]: 2021-03-25 20:39:21.326 Error: Domoticz(pid:18462, tid:18479('DIN-ZIGate')) received fatal signal 11 (Segmentation fault)
'
JanJaap
Posts: 237
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python Frame work error

Post by JanJaap »

Hi, I did not dive into the details, but I got the same errors when writing some not allowed type to the new Configurations, so I added a check for that. Hope that helps.
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
pipiche
Posts: 2034
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Python Frame work error

Post by pipiche »

JanJaap wrote: Thursday 25 March 2021 22:15 Hi, I did not dive into the details, but I got the same errors when writing some not allowed type to the new Configurations, so I added a check for that. Hope that helps.
What do you mean not allowed type ?
JanJaap
Posts: 237
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Python Frame work error

Post by JanJaap »

See the wiki: Callable API on configs. Allowed datatypes to store in config:
String, Long, Float, Boolean, Bytes, ByteArray, List or Dictionary

I solved it like this:

Code: Select all

def setConfigItem(Key=None, Value=None):
    Config = {}
    if type(Value) not in (str, int, float, bool, bytes, bytearray, list, dict):
        Domoticz.Error("A value is specified of a not allowed type: '" + str(type(Value)) + "'")
        return Config
    try:
       Config = Domoticz.Configuration()
       if (Key != None):
           Config[Key] = Value
       else:
           Config = Value  # set whole configuration if no key specified
       Config = Domoticz.Configuration(Config)
    except Exception as inst:
       Domoticz.Error("Domoticz.Configuration operation failed: '"+str(inst)+"'")
    return Config
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
pipiche
Posts: 2034
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Python Frame work error

Post by pipiche »

Ah ok. Here is the issue is on Domoticz.Device , not using Configuration yet.
The plugin as more than 2 years existence


Envoyé de mon iPhone en utilisant Tapatalk
Post Reply