I have a switch that I want to control with the on-board button of my LilyGo T-Display-S3 Touch. I copied 95% of my code from here:
I have already used the device code above for a “Blank” code flash. And some other code that adds LVGL graphics to the screen. I can even press GPIO14 on the ESP32 and see it respond in HA.
For reference I already complete this step:
Settings > Devices & Services >ESPHome > Configure >
Allow the device to perform Home Assistant actions.
I am trying to incorporate the code from here:
So far, I am 0 for 2 in trying to link GPIO14 to the light over my kitchen sink. In one case I use “on_click:” and “on_turn_on” for the other. One code influence by Switch link and the other by Binary_sensor link. Both codes fail. Any direction is appreciated. I don’t know if it is me complicating things, but I sense that I need multiple instances of more YAML code to link GPIO14 to control kitchen_sink_light
`
binary_sensor:
#GPIO0 code not added for brevity
- platform: gpio
pin:
number: GPIO14
inverted: true
name: "Kitchen Light"
on_turn_on:
- delay: 500ms
- switch.toggle: kitchen_sink_light
------------------------------------------------------------
ERROR
[on_turn_on] is an invalid option for [binary_sensor.gpio]. Please check the indentation.
NOTE: It was at this time that I realize that I was using SWITCH code under BINARY_SENSOR...so...I try a new path below.
-----------------------------------------------
binary_sensor:
#GPIO0 code not added for brevity
- platform: gpio
pin:
number: GPIO14
inverted: true
name: "Kitchen Light"
on_click:
min_length: 50ms
max_length: 700ms
then:
- switch.toggle: kitchen_sink_light
------------------------------------------------------------
ERROR
Unable to find action with the name 'switch.toggle'.
-----------------------------------------------