Page 1 of 1

Get device name in LUA script of the device changed

Posted: Wednesday 02 December 2015 15:09
by rgroothuis
Is it possible to get the name of the device that has changed?

I've one IF statement in which I check multiple door sensors. If one of them is triggered I want to print/use the name of which door sensor was triggered. Something like print ("Door sensor: " .. devicechanged[]) has been opened).

Any idea?

Re: Get device name in LUA script of the device changed

Posted: Wednesday 02 December 2015 16:50
by JareckiB12
If devicechanged['name of device'] then print(....) end

Jarecki

Re: Get device name in LUA script of the device changed

Posted: Wednesday 02 December 2015 17:46
by rgroothuis
JareckiB12 wrote:If devicechanged['name of device'] then print(....) end

Jarecki
I know that trick indeed. But that means I get 3 or more if statements. It would be nice and good if there is one print statement with the device name as a variable. That is more efficient coding wise. And I want to use this trick at other places as well.