Home and away push button (momentary) automation

hi all

i want to put a momentary push button (binory sensor) at my door that when leaving the house it will turn off any lights or devices that are currently in the on state. Then when i get home i want to press the same button again to turn on certain lights and devices.

With it being a push button how would i configure this in an automation? i would like to use esphomelib, however a push button wont have a state of ON or OFF, is that correct?

i have the same scenario currently for switching individual lights on and off but this is just using a toggle command, so it doesnt need to be as intelligent as an home or away push of the button.

Is there something simple to achieve this and any examples greatly appreciated

cheers

If my understanding is correct then what I would do is to create an “input_boolean” that gets toggled on every push of the button. Then use the input_boolean state change to on or off to trigger the automation to turn your devices on or off.

ta, yes that makes sense now.