When I leave Turn Lights ON - OFF home

When I leave the house turn on (Foyer Light, Spare Bathroom Light).
When I come home lights stay on for 5 minutes and and then turn OFF.
I don't care what rule I use. I tried Visual Rule. I did something wrong nothing happened when I left or came home.
I tried Rule Machine. The Lights came ON when I left and just stayed ON.

These are just test rules. When I get them working, will use different lights.


Please show a screen shot of your entire rule, not just the actions. Need the whole thing to fully troubleshoot

1 Like

In the first (RM) Rule, you had no logic to turn off the lights when not in away mode. You also did not share the triggers. So, it would be helpful to do as @danabw stated.

In the second (visual) rule, your triggers aren't following the logic. When someone arrives, presence WILL be detected. So, the "when someone arrives" AND "No Presence is detected" are in direct conflict with each other. Not sure how visual rules work with the "or" and "and" statements. But, it looks like it would break down the second half of the OR

So "When Everyone Leaves" OR
"When Someone Arrives AND No Presence is detected"

I would do this as two rules:
1 - When Everyone Leaves -> Turn on Lights
2- When Someone Arrives -> Turn on lights, wait 5 minutes, turn off lights

This has the possibility of not working if someone arrives and leaves before the 5 minute timer. So, you might add an if then statement after the 5 minute wait to check:

Modified #2
When Someone Arrives
-Turn On Lights
-Wait 5 minutes
-If anyone is present Then turn off lights (in this particular situation, no else statement is required because your desired result is already true, lights are still on. The only time the lights should go off is if someone is home.)

Note: Using the rules as set up, the lights will come on EVERY time ANYone arrives and then go off 5 minutes later. This would happen even if one of the other presence devices is already present. It would also turn on the lights (and leave them on) whenever EVERYone leaves.

3 Likes

Here are more screenshots.

Thanks for your help.

Rule Machine 1254 CONDITION
Rule Machine 1254 TRIGGER

Your rule says:

  1. If mode changes to Away, turn on the foyer and spare bath light.
  2. If it changes to anything else, change mode to Away, and turn on the same two lights.

So Mode will always end up being set to Away, and the two lights will always turn on.

What you want (I think) is:

  1. If Mode changes to Away, turn on the lights
  2. If Mode changes to Home
    -- Wait 5m
    -- Turn off both lights

You can do this in one rule, or (simpler) two rules.

  • First rule: Trigger: Mode changes to Away. Actions: Turn on the two lights
  • Second rule: Trigger: Mode changes to Home. Actions: Wait 5 m, Turn off the lights
2 Likes

This or under the else condition remove the mode away statement then change the on to off for the lights.
Any mode other than away will turn off the light.

1 Like

This is how I would approach it.

1 Like

so like this?

I like the little delay. Allows a little time after the geofence mode change to get home.

like this?

Look at ogiewons example. No if then conditional. Since it triggers on Away, no test for away is needed.

1 Like

You are making it to complicated, you don't need any if's or else. See Ogiwan's example above.

1 Like

Don't want to nag, but you should always post a pic of your rule's main page, that shows required expressions (if any) and triggers. Otherwise you may get advice that doesn't fit your actual rule.

This type of screen shot:

3 Likes

I really like this guy's idea. So simple. :smiley:

2 Likes

Depending on tastes, use only one button to toggle it. What I like about hubitat. It is really open and granular.

1 Like

Agree! Choice is indeed good. :slight_smile:

I'm a fan of the 2-rule approach here too... Unless I know that Wait or Delay is comin' pretty soon, I prefer to just move that part to its own distinct rule.

I completely understand there should be no problem leaving a rule open/running for a longer or indefinite time, doing so still just makes me nervous for whatever reason.

Plus, there's a good chance that the "Mode = Home" and "Mode = Away" (and whatever other Mode is... rules will expand over time - having each one distinct gives room to grow.

2 Likes

You have posted many snippets of code asking for suggestions, but you really need to describe what you want this rule to do (Actions) and when it will run (Triggers).

I think I know what you want, as it's a fairly common automation task. In post #7 @ogiewon suggests a method that would work the way that I understand your needs. However the rules you have posted don't come close to to that, so possibly I misunderstand your end goal.

In all your postings so far, you are testing for mode changes. Would it be safe to assume that you have already set up a reliable method to change modes as you come and go from your house?

How many modes have you configured on your hub. For example Away, Day, Night, Home, etc. Do you already have Mode Manager configured to automatically change modes at various times throughout the day? Do you only want the lights to come on when Mode changes to away? Do you want the lights to go off when the mode changes to any mode, other than away, or only a particular mode, Day for example?

2 Likes

This is partially why I suggested using presence, and two rules (also based on OP's original actions and making some educated guesses towards intent). I was not even going to go down the whole rabbit hole of modes while the OP is still trying to get a grasp on some of the basic logic and not knowing how many different modes the OP has. Once the OP gets better at the smaller rules and understanding the logic of triggers and conditions, then they can start working on more complex ones.

Noone present works regardless of the mode name as well as someone arrives. Their original logic appeared to be using presence to determine if anyone was present and only one of them used away mode as a conditional. :man_shrugging:

1 Like

Is a != away an option. Then anything not away will match.