Code that I have not tried to compile, but is included just to let you know what I’m thinking (getting it to work is left as an exercise to the reader! )
switch:
- platform: gpio
// No name or icon is defined, so this physical switch output will not show up in HA
// This switch just exists to control the physical GPIO pin, by using its id value
pin: GPIO0
id: lock_pin
restore_mode: ALWAYS_OFF
- platform: template
// A virtual switch that appears in HA. Turning this switch on will trigger the on_turn_on action,
// which will generate two pulses of the physical GPIO pin by calling the above switch, and then
// will turn itself off. Since there is no lambda expression, the returned on/off status should be
// the assumed status (I think?) which is ON while the output is being pulsed, and OFF when
// the pulsing is done.
name: "Front Door Close"
id: lock
icon: "mdi:door"
restore_mode: ALWAYS_OFF
on_turn_on:
- switch.turn_on: lock_pin
- delay: 200ms
- switch.turn_off: lock_pin
- delay: 200ms
- switch.turn_on: lock_pin
- delay: 200ms
- switch.turn_off: lock_pin
- switch.turn_off: lock
The general idea is to hide the low level switch that runs the pin directly, and create a higher level virtual switch that triggers the low level switch when it is triggered.
You will undoubtedly have to change something in this code to get it to work, but hopefully it’s a start.
There is probably a more efficient way to do this, and if so, I’m sure someone will be along to mention it.