Page 1 of 1

dzVents does not read parameters "devices"

Posted: Sunday 13 October 2024 23:09
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')

Re: dzVents does not read parameters "devices"

Posted: Monday 14 October 2024 1:41
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

Re: dzVents does not read parameters "devices"

Posted: Monday 14 October 2024 19:26
by sooper
I understand now, thanks a lot.