Esphome touch switch

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO25
      mode: INPUT_PULLUP
    name: "Touch sensor"
    filters:
      - delayed_on: 10ms

am trying to use touch buttons as light switch but they only workrs than i set than binary sensors in esp home. but they flickering on then i touch off then i remove my finger how to configure then to only switch on then touch second time i touch it turns off ?

Have you tried momentary switch in esphome ?

Yes, doesn’t register than i use as momentary switch for some reason

This is not a touch sensor:

platform: gpio

This is:

platform: esp32_touch

See documentation here:

You can use a home assistant automation and the the light.toggle service to change the light to it’s opposite state when a touch is detected

trigger:
  platform: state
  entity_id: binary_sensor.touch_sensor
  to: on
action:
  service: light.toggle
  entity_id: light.your_light_here

Or you can automate it on the ESP without home assistant too:

binary_sensor:
  - platform: esp32_touch
    name: "Touch Sensor"
    pin: GPIO27
    threshold: 1000
    on_press:
          then:
          - light.toggle: your_light_here

i ment button like this sorry i written stuff incorrectly

switch:
  - platform: gpio
    pin: D1
    name: "Living Room Dehumidifier"
    id: dehumidifier1

binary_sensor:
  - platform: gpio
    pin: D2
    name: "Living Room Dehumidifier Toggle Button"
    on_press:
      then:
        - switch.toggle: dehumidifier1

Found answer on another forum dunno why didn’t find it sooner but thanks for help !

1 Like
binary_sensor:
  - platform: gpio
    pin: GPIO13
    name: "Kitchen LED TOUCH"
    device_class: motion
    on_press:
      then:
        - switch.toggle: relay1

switch:
  - platform: gpio
    name: "LED"
    pin: GPIO14
    id: relay1
    inverted: True
    restore_mode: RESTORE_DEFAULT_OFF