Page 1 of 1

Persistent data error

Posted: Monday 18 September 2017 20:14
by wizzard72
I'm trying to make a dzVents Lua script with persistent data in it. I have read the documentation on the wiki, but can't find what I'm doing wrong. I'm on version 8394.

Simple script:

Code: Select all

return {	
    active = true,
    logging = {
		level = domoticz.LOG_INFO
		marker = 'TEST '
	},
	on = {
		devices  = {
			'Wasmachine2'
		},
		data = {
            temperatures = {history = true, maxItems = 10}
        },
	},

	-- actual event code
	-- in case of a timer event or security event, device == nil
	execute = function(domoticz, device)

        domoticz.data.temperatures.add(device.state)

	end
}
Can someone help me?

I see the following error in the log:
2017-09-18 20:07:37.765 Error: dzVents: Error: 0-Watt : An error occured when calling event handler dzVentsTest
2017-09-18 20:07:37.765 Error: dzVents: Error: 0-Watt : ...moticz/scripts/dzVents/generated_scripts/dzVentsTest.lua:20: attempt to index field 'data' (a nil value)

Re: Persistent data error

Posted: Monday 18 September 2017 20:49
by dannybloe
You have to define the data section as a sibling of the on-section. Not inside the on-section.

😀

Re: Persistent data error

Posted: Thursday 21 September 2017 14:25
by wizzard72
Thank you, it's working now