Presence + Time in Rule Machine

smartapp
presence
rulemachine

(Erwenger) #1

OK. So I have Rule Machine. Love it. I want to make a rule that triggers a switch if:

  1. Time is in a certain range (e.g., sunset to sunrise); AND
  2. Presence detector is found to be in range at any point during the time range above. (I don’t want to specifically target arrival. Just presence).

I can make a rule that triggers when Presence “arrival” is triggered during the target time range.

BUT what if I want to same rule to execute if the presence detector (e.g.,) phone is already in the geofenced area when the target time (e.g., sunset) occurs?

Thanks


(Brian Diehl) #2

For this you can set up a Virtual Switch and a separate rule to control it.

Set the Switch to ON when you are present and have it switch to OFF when presence is no longer detected. It will stay on for the duration of your presence.

Then just use the Virtual Switch in your concept above.


(Erwenger) #3

OK. So then the Rule Machine trigger would be:

  1. If in target time range; AND
  2. Virtual button is on

THEN trigger switch?

Clever. But they should add a “presence” mode for presence in Rule Machine! Would be simpler.
Thanks!


(Brian Diehl) #4

Yes. That will do what you are looking for.

I know there are some other presence options out there such as SharpTools and also using a router with DD-WRT detecting when your phone connects to it but I don’t know if they actually track constant presence compared to arrival and departure.


#5

Maybe I am missing something, but this one seems easy?
You can choose a presence sensor being present as a condition.
Just make a rule, don’t need a trigger.

Conditions: presence sensor present, time between sunrise and sunset
Rule: presence sensor present AND time between sunrise and sunset


(Brian Diehl) #6

Yea. That is true. As long as the presence is set up as a condition and not a trigger it will just be on for the time he is present.

I think I was looking at it being a trigger (and I think the OP may have been, too), since the trigger works based on the sensor becoming present (the state).


(Bruce) #7

You are missing a key point: the event of arriving causes the state of present to be true. With a condition, the rule is going to be evaluated upon each presence event, i.e., arrival and leaving. It will be true as long as the presence is present. For example, were there some other condition (or trigger) that caused the rule to be evaluated, the presence condition would be true when tested (i.e., it didn’t require an arrival event, but was determined to be the case upon some other event).

This is the case, as above.

As to your original post, something is going to have to cause a trigger or rule evaluation to occur. It doesn’t just sit there looking at things, something has to happen. So if all you have is presence and a time period, the only things that can cause it to fire or evaluate are the two time period endpoints, and the arrival or departure of the presence sensor. [quote=“erwenger, post:1, topic:38166”]
BUT what if I want to same rule to execute if the presence detector (e.g.,) phone is already in the geofenced area when the target time (e.g., sunset) occurs?
[/quote]

Then you have to use a rule with the time period as a condition and the presence as a second condition.


(Erwenger) #8

Correct. I didn’t originally see that you could choose a condition instead of a trigger. I set condition to present and it works. thx.