I have a virtual switch which indicates if my house is occupied. When it is set to ‘unoccupied’ I want all security sensors - PIR, door/window sensors - when activated, to invoke a central Lua routine. Any advice on how best to implement this with a view to minimising the amount coding required by each device?
Here’s one way:
Make a scene, call it “Sensor Tripped”. Add all of the security sensors as triggers. This will fire every time any sensor is tripped, whether your house is occupied or not.
In the scene’s Luup tab, put this code at the beginning:
local SwitchId = 123 -- Device number of occupancy switch.
local isOccupied = luup.variable_get("urn:upnp-org:serviceId:VSwitch1", "Status", SwitchId)
if (isOccupied == "1") then return end -- Assuming switch is on for occupied, off for unoccupied.
Then put the Lua code you want to run when a sensor is tripped while unoccupied.
Thanks futzle. I was hoping there was an elegant solution.