Esphome example switch: Difference between revisions
Jump to navigation
Jump to search
(Created page with "This example shows a toggle switch. It is either on or it's off. That is the LED follows the switch state. <nowiki># A physical switch or button should be a binary sensor if you are detecting something like grounding the pin. # Physical Button on D1 (GPIO5) binary_sensor: - platform: gpio pin: number: D1 inverted: False mode: INPUT_PULLUP name: "Wemos Test Button" on_press: then: - switch.turn_on: led on_release:...") |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This example shows a toggle switch. It is either on or it's off | This example shows a toggle switch on D1 (GPIO5). It is either on or it's off and it turns the LED on D0 (GPIO16) on or off. | ||
<nowiki># A physical switch or button | <nowiki># A physical switch or button is a binary sensor. It is used to detect something like grounding a GPIO pin. | ||
binary_sensor: | binary_sensor: | ||
- platform: gpio | - platform: gpio | ||
| Line 16: | Line 14: | ||
on_release: | on_release: | ||
then: | then: | ||
- switch.turn_off: led</nowiki> | - switch.turn_off: led | ||
switch: | |||
- platform: gpio | |||
name: "Wemos Test LED" | |||
pin: | |||
number: D0 | |||
mode: output | |||
id: led | |||
internal : true</nowiki> | |||
{{template:top}} | {{template:top}} | ||
=Navigation= | |||
[[ESPHome|Return to the ESPHome page]]<br> | |||
Latest revision as of 23:17, 27 August 2023
This example shows a toggle switch on D1 (GPIO5). It is either on or it's off and it turns the LED on D0 (GPIO16) on or off.
# A physical switch or button is a binary sensor. It is used to detect something like grounding a GPIO pin.
binary_sensor:
- platform: gpio
pin:
number: D1
inverted: False
mode: INPUT_PULLUP
name: "Wemos Test Button"
on_press:
then:
- switch.turn_on: led
on_release:
then:
- switch.turn_off: led
switch:
- platform: gpio
name: "Wemos Test LED"
pin:
number: D0
mode: output
id: led
internal : true