Lights for Multiple Presence Detection

I want 2 lights to come on at a certain level when either my wife or I arrives home in a time range, however I don’t need them to come on if one of us is already home. Is this correct or will these conditions cancel the action?

I don't think this will do what you want if you both arrive home together (the light will not turn on).

The way I handle this is I have a virtual presence device (called "anyone") that is the logical OR of myself and my wife's presence. I can then trigger events off of this virtual device's arrival or departure-- if "anyone" "arrives", that must mean that the house had been empty and AT LEAST ONE of us is now home. I also trigger when "anyone" "departs"-- this is a bit of a misnomer because it only triggers when EVERYONE is gone from the house.

That's a clever way of handling it. We use modes and trigger a similar lighting automation for when mode changes from Away to one of the home modes. If I'm already home, then the house is already in one of the home modes, and the lighting automation won't fire when my wife gets home.

1 Like

No, that will not work the way you want it to. You have the conditions correct but they have to come BEFORE that action you want to take. Swap the order of your two actions and add an END-IF to the end and you should be good to go.

@andrewL this is what I’m trying to achieve, would you mind providing a little more detail on how you set that up? New to HA and presence has been giving me a bit of a hard time

Just takes a few steps:

  1. create a virtual presence device which will represent the combo of you and your wife
  2. create a rule to set the presence status of this virtual device: if either you or your wife are present, the virtual device is present, else it's not present

Then you can trigger off of the virtual device. If the virtual device is "present", then at least one of you is home. If the virtual device is "not present", then no one is home.

Thanks for taking the time to respond, but I must be missing something. Can’t seem to figure out how to set the presence status of the virtual device I created from the presence of my OR my wife’s phone. It makes sense to me but the process is eluding me. If you could spell this out a little more for me I’d really appreciate it

Why do you want to complicate things with a virtual device? You don't need to use a virtual device to accomplish what you want. Your rule was right, you just had the actions in the wrong order. Using a virtual device is not going to fix your rule.

Ryan is correct. Reverse the order and that will fix your rule.

IF Time between x and y AND Brian, Jessica not present THEN
do stuff

1 Like

Both of them are out of the house. Then both of them arrive home at the same moment. Does the rule do the correct thing? It doesn't, from my understanding of what was described in the OP.

Edit to add: maybe OP doesn't want the light to go on if they both arrive home together. But when I set this up, I did, hence a virtual presence device.

What? Why would you not want the light to go one if you arrive home at the same time. Also, you will never arrive in Hubitat at the same time... One will always arrive first. So, in that case, you will turn the light on, then turn it off?
Not turning it on if someone is already home can also be done very easy via RM. You simply don't turn it on if they are both home. But in this case you do not need a virtual sensor either. The virtual sensor just adds complexity, IMHO.

Are you saying there's no possibility that the second person's presence is updated to present between the trigger and the rule condition evaluation? That hasn't been true based on my experience, and I see the possibility of a race condition here.

We can discuss that possibility if you want also but that has absolutely nothing to do with a virtual sensor. You will have the same reporting from the two phones if a virtual sensor is used or not. Adding the virtual sensor just adds a longer process to process both messages exacerbating any potential issue. Not mitigating it.

But no, in my experience, you are never going to get location updates from two phones that are less than 1s apart. The odds of both phones updating to Hubitat in that close a time-frame are so astronomical I can't even begin to calculate it.

No, it's different behavior with a virtual sensor. This potential race condition does not exist if you OR the two presence sensors together FIRST and trigger off of that.

How do you figure? You still have the rule being called up for each of the triggers. It doesn't matter what the condition within the rule are. A different instance of the rule is called every time a trigger happens. You are just moving that from the light rule to the rule to aggregate the sensors.

But anyway, it's not going to happen anyway so stop trying to obfuscate the issue. You don't need a virtual sensor.