GPIO Switch

The gpio switch platform allows you to use any pin on your node as a switch. You can for example hook up a relay to a GPIO pin and use it through this platform.

# Example configuration entry
  - platform: gpio
    pin: 25
    name: "Living Room Dehumidifier"

Configuration variables:

  • pin (Required, Pin Schema): The GPIO pin to use for the switch.
  • name (Required, string): The name for the switch.
  • id (Optional, ID): Manually specify the ID used for code generation.
  • All other options from Switch and MQTT Component.


esphomelib will attempt to restore the state of the switch on boot-up and write the value very early in the boot process.

Please note that certain pins can have pull-up/down resistors that activate/deactivate a pin before esphomelib can initialize them. Please check with a multimeter and use another pin if necessary.