Domoticz crashes on complex data in customEvent  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
sabcio
Posts: 2
Joined: Saturday 21 March 2020 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Domoticz crashes on complex data in customEvent

Post by sabcio »

Hi,

trying out customEvents but my domoticz service crashes each time I try to send some more data

Code: Select all

2020-03-21 10:58:19.235 MQTT: Topic: domoticz/in, Message: {"command":"customevent","event":"notResponsive","data":[{"idx":29,"test":"ok"}]}
2020-03-21 10:58:19.244 Error: Domoticz(pid:32647, tid:32690('EventSystemQueu')) received fatal signal 6 (Aborted)
2020-03-21 10:58:19.244 Error: siginfo address=0x7f87, address=0xffffffff
I've tried different payloads, every time a valid json. The only thing that works is when data is a plain integer, string value:

Code: Select all

Message: {"command":"customevent","event":"notResponsive","data":29}
Does not work:

Code: Select all

Message: {"command":"customevent","event":"notResponsive","data":[{"idx":29,"test":"ok"}]}
Message: {"command":"customevent","event":"notResponsive","data":{"idx":29,"test":"ok"}}
The script doesn't do anything yet, it just logs data output:

Code: Select all

return {
	on = {
        customEvents =
        {
            'notResponsive',
        }
	},

	logging = {
        level = domoticz.LOG_DEBUG,
        marker = "BatteryStatus"
    },

	execute = function(dz, item, info)
		dz.log(item.data)
		dz.log(item.isCustomEvent)
	end
}

EDIT1: I thought I should parse json but it still failed and then I tried empty execute function which also crashes.
MrHobbes74
Posts: 115
Joined: Sunday 19 January 2020 22:29
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

Re: Domoticz crashes on complex data in customEvent

Post by MrHobbes74 »

Can you try to put the data json in a string? I think that is the problem. I’m not 100% sure, but I think you can’t provide a json object, you can only provide a string, that can contain a json object.

{"command":"customevent","event":"notResponsive","data":”[{"idx":29,"test":"ok"}]”}
sabcio
Posts: 2
Joined: Saturday 21 March 2020 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz crashes on complex data in customEvent

Post by sabcio »

Ok, that does work, thanks MrHobbes74. Does not make sense to me but I'm no lua expert. Here's a working example

Message payload:

Code: Select all

{"command":"customevent","event":"notResponsive","data":"{\"idx\":29,\"test\":\"ok\"}"}'
Function:

Code: Select all

	execute = function(dz, item)
	    dz.log(item.data["idx"])
	    dz.log(item.data["test"])
	end
MrHobbes74
Posts: 115
Joined: Sunday 19 January 2020 22:29
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

Re: Domoticz crashes on complex data in customEvent  [Solved]

Post by MrHobbes74 »

It has nothing to do with Lua. The reason is that the parameter ‘data’ can only contain a string. In that string, you can also put a flat raw json string. As long as it is a string 😉. In dzVents, if the string contains a json object, it allows access to the object. In other cases (no json object) you get the whole string.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest