Python plugin: updating a device, Domoticz crashes

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
User avatar
psubiaco
Posts: 222
Joined: Monday 20 August 2018 9:38
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Italy
Contact:

Python plugin: updating a device, Domoticz crashes

Post by psubiaco »

Hi,
Since many months when my python plugin (using the legacy framework) try to update a device, often it crashes Domoticz.

For example, having an incremental counter (used as a rain meter), if the python plugin run

Code: Select all

Devices[Unit].Update(TypeName='Counter Incremental', nValue=0, sValue='276421', Description='ID=ff37.2,IN_COUNTER,', Options={'ValueQuantity': 'Pluviometro', 'ValueUnits': 'mm'})
I get the following errors:

Code: Select all

2023-05-29 15:05:35.101  Error: GetJSonDevices: exception occurred : 'stoll'
2023-05-29 15:05:35.104  Error: Domoticz(pid:17760, tid:17793('EventSystemQueu')) received fatal signal 6 (Aborted)
2023-05-29 15:05:35.104  Error: siginfo address=0x4560, address=(nil)
2023-05-29 15:05:35.115  Error: GetJSonDevices: exception occurred : 'stoll'
2023-05-29 15:05:38.367  Error: Did not find stack frame for thread (LWP 17793)), printing full gdb output:
With other device types I fixed by removing bad options items that were not suitable for that kind of devices (for example, if I have a incremental counter port that want to convert to a digital input port, I have to remove the options relative to the incremental counter device).

In the past, 1 year ago, there was not any trouble even specifing a bad options, Domoticz never crashed.
Hoping that @Dnpwwo or someone else help me finding the best way to avoid crashes.
Thanks a lot.
Paolo
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: updating a device, Domoticz crashes

Post by waltervl »

What if you skip the description update part? As this is not common practice the plugin framework is perhaps not anticipating this enough?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
psubiaco
Posts: 222
Joined: Monday 20 August 2018 9:38
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Italy
Contact:

Re: Python plugin: updating a device, Domoticz crashes

Post by psubiaco »

waltervl wrote: Monday 29 May 2023 22:40 What if you skip the description update part? As this is not common practice the plugin framework is perhaps not anticipating this enough?
For Domoticz, the description field is just a silly useless text, while for my plugin the description field is the way that user can configure hardware (digital or analog input, counter, dimmer, ...) so I have to update the description field.
I suppose the problem is on updating Options dictionary (in this case Options is updated with the same content as before).
Unfortunally I cannot say from which version the problem started happening.
I'll try to investigate better on the problem, focusing on Options dict
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: updating a device, Domoticz crashes

Post by waltervl »

Stoll is a function to convert strings into long integers.
So the total Json string including nvalue and sValue gets perhaps messed up by incorrect values in the description or other part of the Json.

This probably is introduced in the Domoticz version wherethe python framework is reworked to be future proof using Python ABI (if I remember correctly). This was a few stable versions back.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest