Automation to increase dimmer to 100% for 5 minutes when arriving home

Where we live is dark! I’m trying to replace a WebCoRE piston that used to brighten lights to 100% when somebody comes home and then dim them again after 5 minutes. I’m using a virtual switch and have the following automation to kickoff the brightness increase:

I then use the following automation that watches the virtual switch (Outside vSwitch) to start a timer and then dim the lights after 5 minutes and then turn the virtual switch off again:

What happens though is that once the first routine is triggered by coming homes the routine goes in to an endless loop (so Off (30s) → On (5m) → Off (30s) → On (5m) → Off (30s) and so on)

This seems to imply the first automation is always running when we are home? What am I missing? Perhaps I need to use a presence switch? Curious for some ideas. Thanks in advance.

I think it’s because part of the trigger in the first routine is the vswitch turning off. So every time, the second routine turns off the vswitch, the first routine is triggered and the process repeats.

I think the trigger in the first routine needs to be something other than the state of the vswitch. What condition does the vswitch being off supposed to represent?

I think I might have the condition be “Barn Outside Lights On” and “Barn Outside Lights at 7%”.

Thanks for taking a look, the first routine is supposed to be checking the status of the switch, not operating it:

image

So, somebody gets home AND the switch is off… Maybe I’m missing the point, I think I also added this to try and workaround the issue…

Are you trying to check the state of the physical “Barn Switch” or the virtual “vSwitch”? Because as written, every time the second routine turns off the vSwitch, the first routine will be triggered. A pre-condition of “vSwitch is off” would check the state of vSwitch without being a trigger for the first routine.

I think I’m checking the state of the virtual vSwitch, surely the “if” implies a check of state and not a change to that state??? The second routine has to turn off the vSwitch in readiness for the next time somebody comes home, in essence I’m hoping to use the vSwitch as a variable. Not to say that I don’t fully comprehend how this “stuff” works!

Then I suggest changing the state check of vSwitch to a pre-condition so that when it is turned off in the second routine, it isn’t a trigger in the first routine.

1 Like

I just made the change and will test this evening. I’ll report back once I know more. Thank you for helping, I really appreciate it. :slight_smile:

1 Like

It looks like this did the trick, I only have one data point but the behavior last night looked much better. Once again thank you for your help. I’m not sure I understand but I rationalize it as:

Without pre-condition it’s like saying (pseudo code):

if the vSwitch is switched off then:
   do something

Vs, the pre-condition is:

if the vSwitch is off then:
   do something

The difference being “switched”. I realize my other routine relies on this very same logic of “switching”:

image

So I guess there has a way to differentiate between a state change and a simple condition.

One is checking the state and the other is reacting to the state change.

Pre-condition - Only when device/Location_mode/presence is in some state, react to the trigger condition and preform the action(s). “If the door is locked (precondition), when there is motion detected, send a notification and set off an audible alarm”

Trigger condition - When device/Location_mode/presence state changes and matches the trigger condition(s), perform the action(s). “If the door is locked (goes from unlocked to locked) and motion is detected, send a notification and set off an audible alarm”

Thanks, so I think I’m correct with what I’m thinking?