@aecchalet
You’re welcome.
Now I am trying to create a scene where when any of my listed sensors trip (armed or not), it will send a message to me. I only want this scene to execute when my virtual device status = 0 indicating unoccupied.
I changed the above code accordingly to:
–Run this scene if unoccupied (status = 0)
–OCCDevice is virtual switch/device, OCC “Occupied”
local OCCDevice = 45
local OCCStatus = luup.variable_get(“urn:upnp-org:serviceId:VSwitch:1”, “Status”, OCCDevice) or “0”
if (OCCStatus == “0”) then
return true
else
return false
end
However, currently my virtual device status = 1 (occupied), yet I am getting messages from all of my sensors that trip??
I created a trigger for each sensor by 1st choosing the sensor and the event “A sensor is tripped.” For each trigger, I chose the option to be notified if the sensor is tripped. In the Luup tab window, I pasted the above Lua code. Could it be that the message is sent before the Lua code is run?
The sequence of execution processing for a scene with a trigger is as follows:
[ul][li]A trigger initiates processing[/li]
[li]If the LUA code for the trigger returns false, than stop. It will continue if your return true or NOTHING[/li]
[li]If the LUA code for the scene returns false, than stop. It will continue if your return true or NOTHING[/li]
[li]Execute all of the specified device commands.[/li][/ul]
What happens when you drop the or “0” from the assignment to OCCStatus ?
“What happens when you drop the or “0” from the assignment to OCCStatus ?”
Nothing different.
When I looked at the Lua code box for each of the triggers, some were empty (not used yet) and others had text from what appeared to be Vera Alerts. Can I still put Lua code in the box for each trigger with Vera Alerts using that space?
Can I still put Lua code in the box for each trigger with Vera Alerts using that space?Yes ... Just put them after the Vera Alerts code. If you want conditional notification you can:
if (somecondition) then
… Existing Vera Alerts Code …
end
It’s important that you keep all of the existing code and the comments intact.
Nothing different.You might have some other syntax error in the code earlier ... post the complete code that you use in the lua (including comments!) If it can't parse and execute it .. it will continue as if you returned true.
I think that my scene continued to send me unwanted messages because I put my Lua code in the scene LUUP code box, not the trigger Luup code box. I may try your suggested solution but first, I want to see if I can do this function with your PLEG!
Thanks