Question about the use of activated device

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

Moderator: leecollings

Post Reply
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Question about the use of activated device

Post 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
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Question about the use of activated device

Post 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
Last edited by dannybloe on Wednesday 26 July 2017 18:53, edited 1 time in total.
Reason: I wasn't correct.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Question about the use of activated device

Post by schulpr »

Thanks! I didn't know it was that easy :lol:
Last edited by schulpr on Wednesday 26 July 2017 19:59, edited 1 time in total.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Question about the use of activated device

Post by dannybloe »

That's why there is 'easy' hidden in 'dzVents' :)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest