Fibaro – two triggers and time interval
I wanted to implement a scenario with two different motion sensors triggering a single lamp. But I wanted to ensure that this behavior was only applicable during a special time interval. The solution looks like this (and please mind that the references to the devices are of course applicable only to my system).
This is the trigger section; The important learning here is the structure of the operators and conditions. “All” basically means AND whereas “Any” means OR.
{
operator = "all",
conditions = {{
operator = "all",
conditions = {{
type = "date",
property = "cron",
operator = "match>=",
value = {"15", "0", "*", "*", "*", "*"}
}, {
type = "date",
property = "cron",
operator = "match<",
value = {"59", "6", "*", "*", "*", "*"}
}}
}, {
operator = "any",
conditions = {{
id = 364,
isTrigger = true,
operator = "==",
property = "value",
type = "device",
value = true
}, {
id = 232,
isTrigger = true,
operator = "==",
property = "value",
type = "device",
value = true
}}
}}
}
This is the action section:
local motion1 = 364; -- ID for PIR Motion Sensor - Livingroom
local motion2 = 232; -- ID for PIR Motion Sensor - Hallway
local starttimer = 120; -- Time for light to be on in seconds
local horntimer = (starttimer); -- timer
fibaro.call(switch, "turnOn");
fibaro.debug("green", "Start: Light on");
------------------ Starting loop ----------------------------------------
repeat
horntimer=horntimer-1;
fibaro.debug("Update",timer)
fibaro.sleep(1000);
-- if movement then restart timer------------------
local value movement = fibaro.get(motion1, "value");
if movement == true then
horntimer=starttimer;
fibaro.debug("grey", "I see movement. Timer reset");
end
local value movement = fibaro.get(motion2, "value");
if movement == true then
horntimer=starttimer;
fibaro.debug("grey", "I see movement. Timer reset");
end
until (horntimer<1)
fibaro.call(switch, "turnOff");
fibaro.debug("red", "End: Light off");
Leave a Reply