dzVents does not read parameters "devices"

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

Moderator: leecollings

Post Reply
sooper
Posts: 3
Joined: Wednesday 02 October 2019 11:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

dzVents does not read parameters "devices"

Post by sooper »

Hi,

I tried running a default dzVents script in Domoticz.

Code: Select all

return {
	on = {
	    timer = {
	        'every minute'},
	    
		devices = {
			'Alarm'
		}},
	execute = function(domoticz, device)
		domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
	end
}



The result I got
Error: dzVents: Error: (3.0.2) ...domoticz/scripts/dzVents/generated_scripts/Script #3.lua:16: attempt to concatenate a nil value (field 'name')
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: dzVents does not read parameters "devices"

Post by waltervl »

You have set 2 triggers:device and timer.
If timer is triggered the input of the execute function is not a device but a timer object. In the documentation the second object of

Code: Select all

execute = function(domoticz, device)
is called item instead of device to indicate it can be anything depending on the trigger

So if you want to continue with 2 triggers you first have to check what the trigger was, device or timer.

For example (from documentation):

Code: Select all

return {
    on = {
            timer = { 'every 5 minutes' },
            devices = { 'myDetector' }
    },
    execute = function(domoticz, item)
        if (item.isTimer) then
            -- the timer was triggered
            domoticz.devices('myLamp').switchOff()
        elseif (item.isDevice and item.active) then
            -- it must be the detector
            domoticz.devices('myLamp').switchOn()
        end
    end
}
See also the wiki for more information:
https://www.domoticz.com/wiki/DzVents:_ ... .80.A6_end
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
sooper
Posts: 3
Joined: Wednesday 02 October 2019 11:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: dzVents does not read parameters "devices"

Post by sooper »

I understand now, thanks a lot.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest