I’m very new to the ESPHome project, and I’m struggling with something very basic.
I have a light that is connected to a smart outlet. The smart outlet is connected to Home Assistant and works fine. It’s even part of an automation where if my 3D printer is turned on (also connected to a smart outlet), then the light is automatically turned on.
I want to connect a button to an ESP8266 running ESPHome, and when I press that button, it toggles the state of the light. Alternatively, I could connect a switch to the ESP8266 to do the same thing.
I’ve added this code to the YAML for the ESP8266:
binary_sensor:
id: my_button_id
name: my_button_name
platform: gpio
pin:
number: GPIO14
mode:
input: true
pullup: true
I’ve used the ESPHome Compiler to compile and install the YAML. But when the device reboots there aren’t any triggers for me to create an automation with.
I’ve tried to add an on_press section:
on_press:
then:
switch.turn_on: switch.3d_printer_lights
It won’t compile giving me an error saying “Unable to find action with the name ‘switch.turn_on’.”
I’ve also tried switch.toggle as shown here.
I’m sorry if this is a really basic thing and I’m missing something very obvious. I’m just not seeing it. I’d appreciate any help I can get to make this work.
Thanks!