Identifying trigger from scene Luup

Hello,

I have a scene triggered by several different devices. The devices are all motion sensors, each one in a different room, that have the same effect - hence the need for a single scene with a single piece of code.

However, from this code, I would like to log which device has triggered the scene.
How can I do this? Does the Vera set some variables when executing the Luup code for a scene, with information such as this one?

No, sadly not. The only way is to set a global variable in each trigger Lua for the scene code to examine.

I have an similar case. What are you seeking to do with the information? Put in the log? Make a notification?
What I ended up doing is exactly what akbooer is suggesting. I created a global variable and gave it a different value in the trigger lua for each trigger. I then use the value in a TTS announcement.

The only way that I can think to do it would be one scene per trigger device, and use LUA in the scene update a local variable for the device to indicate which trigger device activated it last / most recent.

If all you’re looking for is an alert to tell you which device triggered it, then you don’t even need the LUA code.

Thank you all: apparently we’re all using the same solution :slight_smile: yes, I am currently setting a global variable in the Lua code for each trigger.
What I find suboptimal (not very clean code) is that the values for this global variable all have to be hardcoded - while, in principle, I would be fine obtaining e.g. the name of the device, or one of the device’s attributes, and using that string.

FYI, what I’m doing is the following: the triggers are motion sensors, and this is for the alarm part of my HA setup.
When a motion sensor is armed and detects motion, I have a bunch of things happening that are defined in the Lua code for the scene (lights, sirens, camera recording, notifications being posted to the family via a Slack channel, etc.). In the notification text, I want to specify which sensor has triggered the alarm - as in “Motion detected in the hallway - sounding alarm”.
Similarly, I am logging certain events, e.g. when the system is armed/disarmed via a key fob: I want to log whose key fob that was, but otherwise I want to use the same piece of code instead of replicating code unnecessarily.

If only one specific sensor could be the trigger for a scene at any given time, you could poll ALL of them to see which has the most recent status change and that would be the one that is triggering the scene.