Page 1 of 1

Question about the use of activated device

Posted: Wednesday 26 July 2017 18:30
by schulpr
Hello,

I have a question. It it possible to retrieve the device IDX that is responsible for the actual trigger? Like in this little script:

return {
active = true,
on = {
devices = { 'SENSOR_*' } ( or perhaps in something like this: "devices = {74, 21, 71, 164}" )
},
execute = function(domoticz, sensoren)
if sensoren.state == 'Open' then
domoticz.devices('Magneetsensors').switchOn()
domoticz.log('<font color="red">Een deur- of raamsensor is geactiveerd.</font>', domoticz.LOG_INFO)
end
end
}

I would like to use the activated sensor in another script or put the value in a variable.

Thanks again for all the excellent work!

Regards, Rob

Re: Question about the use of activated device

Posted: Wednesday 26 July 2017 18:51
by dannybloe
The second parameter (device) is the device that has been changed:

Code: Select all

execute = function(domoticz, device) 
	print(device.id) -- this is the triggered/changed device.
end

Question about the use of activated device

Posted: Wednesday 26 July 2017 19:59
by schulpr
Thanks! I didn't know it was that easy :lol:

Re: Question about the use of activated device

Posted: Wednesday 26 July 2017 20:01
by dannybloe
That's why there is 'easy' hidden in 'dzVents' :)