GPIO Switch: simplify Momentary Switch example (#1121)

Simplify case and avoid the need to use a secondary template switch.
Use `on_turn_on` directly to trigger the delay and turning off afterwards
This commit is contained in:
Adrián Panella 2021-05-17 10:04:34 -05:00 committed by GitHub
parent 1b748284f6
commit 0eb2dc1fe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,7 +63,7 @@ Momentary Switch
----------------
To create momentary switches, for example switches that toggle a pin for a moment, you can use
:doc:`template switches <template>`.
`on_turn_on` trigger.
An example that uses a single relay to activate a remote control button. The button can only
start or stop the motor of the gate. In itself, the button or remote can not know if it opens
@ -76,11 +76,9 @@ or closes the gate. The relay simulates the button press for 500ms.
- platform: gpio
pin: 25
id: relay
- platform: template
name: "Gate Remote"
icon: "mdi:gate"
turn_on_action:
- switch.turn_on: relay
on_turn_on:
- delay: 500ms
- switch.turn_off: relay