How to setup a light to turn on when a door opens/closes the first time and then off when it opens / closes the next time

So I have a Phillips Hue outside my back door and I would like it to turn on at night time when the door opens. I’ve set it up using the smart lighting app in automations using the Samsung multi-purpose sensor and only after sunset, etc… this works fine.

However when I come back in (e.g. I take my dog out…open the door, go outside, close it behind me, walk my dog around the yard and then come back to open the door to go inside) I want the light to turn back off.

I thought the mirror behavior option might work for this assuming that if the light is on it will turn it off and vice-versa. But that doesn’t seem to be the case. I also tried creating two routines one for when the light is on (turn off the light) and one for when it is off (turn on the light) but this seems to execute at the same time so when the light is on and I open the door it starts to turn off for a split second but then it is as-is the second routine kicks in and sees that it is off (or turning off) and then turns it back on.

Seems like a simple thing to do (basically toggle the state of the light when the door opens after dark) but what am I missing?

Thanks in advance

OK, I am going to say check out webCoRE. You can go to the webCoRE community forum and get some advice on creating a piston that can accomplish what you want. There are a few users who enjoy helping others build their pistons.

1 Like

Take @jkp’s advice. I don’t think you can create what you want within ST. What you want can easily be created with webcore. There are many of us in the webcore community who will help you design exactly what you described above.

1 Like

Rather than specifically turn the lights on or off, try toggling them. So what was off will turn on, and what was on will turn off.

1 Like

I actually did just that with webCoRe so I also recommend you go there. My solution is not the best, I don’t think, as I think I have some unnecessary steps making it more complex than it needs to be. I’m pretty sure others got the same thing setup in a less complicated way than I did it. But I can confirm it is possible with webCoRe.

1 Like

You can always post an image of your piston on the webCoRE community forum and ask for input. There are some users who enjoy helping other users improve their code. :slight_smile:

1 Like

I would, but since we’ve moved to a new house, I had to do something completely different for the outdoor light where the dog goes out. So it, and a few other pistons I don’t use but don’t have the heart to delete are paused.

you could technically do it with Automations in the SmartTHings app and a virtual switch, but webcore is easier when you can just import from this:

Alright, thanks everyone. I was hoping I was just missing something in ST as it would be easier if I just missed a setting, but sounds like there is a bit of a bug there. I’ll give the webcore a try

Thanks