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.
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.
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.
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.
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.
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?
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.