This page last changed on Jul 23, 2015 by madspoulsen.

I'm trying to set up a rule with this flow.

Rule "turn off water boiler on high power usage"
When
waterboiler, state=on
Powermeter value > 1000
then
Turn off water boiler
end

/this is the tricky one/
Rule "when water boiler status OFF and high power usage, notify resident"
when
waterboiler, state=off
Powermeter value > 1000
then
wait 20 seconds /* to stabilize power and update power meter */
if powermeter value > 1000
then
notify by sonos speaker.

The part i can't figure out is where the rule waits some seconds and after that, test a value which can lead to the action.

Any ideas?

Add

timer(int: 20s)

before

when
and improve syntax.

Posted by aktur at Jul 24, 2015 08:54

Thanks for your reply, Michal.

I'm trying to have a rule triggered on a switch. that's fairly simple.
But in the "then" statement, i will define an action.
wait 20seconds
and execute another action.

Like having a PIR sensor turning on the light.
If PIR is activated, then turn on the light.
If not re-ativated within 20seconds, turn off the light.

does it make sense?

Posted by madspoulsen at Jul 25, 2015 01:17

I'm trying to have a rule triggered on a switch. that's fairly simple.
But in the "then" statement, i will define an action.
wait 20seconds
and execute another action.

It is not a good idea to wait within rule's "then" statement. You will hang the whole rule engine. A much better solution is the one I've given in my previous post.

Like having a PIR sensor turning on the light.
If PIR is activated, then turn on the light.
If not re-ativated within 20seconds, turn off the light.

You just need 2 rules, one for switching light on and one for switching light off. Like this:

rule "PIR light on"
when
  Event(source=="PIR", value=="on")
then
  execute.command("Light-on");
end

rule "PIR light off"
timer(int: 20s)
when
  Event(source=="PIR", value=="off")
then
  execute.command("Light-off");
end
Posted by aktur at Jul 25, 2015 11:01
Document generated by Confluence on Jun 05, 2016 09:33