Trigger : door closes
Condition : binary sensor on
Actions :
binary sensor off
condition: light is on
turn light off
And if you want a maximum delay between open and close, you will add a third automation to reset the binary sensor:
trigger : binary sensor on for XXX minutes
action : binary sensor off
Sorry, I meant ‘input boolean’.
Any input_XXX acts just like a variable so you can use them to store your status. This way, you know if you’ve started an automation prior to the trigger or not.
Ah yes that is exactly what I was looking for. I was already confused that such a thing wasn’t a part of HASS and I had to do it using my MQTT work-around. Turns out I just didn’t know what to search for.
I’ve also seen a user that made a variable custom component, but I can’t find it now. (storing value across restarts &so)
From your automation, I guess you have the xiaomi sensors ? (158dXXXX) You have immediate notification of the open/close status ? I’m wondering, my kit is still in transit…
Even though you seem to have it solved already, an alternative, simplified, approach would be the to use the light.toggle service. Since you’re doing nothing else than turning on or off, toggeling the lights would already do what you want.
For more complex automations though the usage of the input_boolean as a helper of course is a good solution. Just wanted to point out another way for doing this.
The thing is that there was a “complex” condition in place here for deciding if I was coming home or going out, but looking at 2 consecutive actions. So a simple toggle wouldn’t suffice