ESP_Home binary sensor to toggle Lights

Hi Guys,

i wanted that implement that when I press number GPIO0 button I toggle the entity light.garage_lights (zigbee lights)

With this code I’m getting this error “Unable to find action with the name ‘light.toggle’.
light.toggle: light.garage_lights [source /config/esphome/garagesensor01.yaml:57]” with this

binary_sensor:

  - platform: gpio
    name: "Garage Motion"
    device_class: motion
    pin: 
      number: GPIO1

  - platform: gpio
    name: "Garage Button"
    pin: 
       number: GPIO0
       inverted: True
    on_click:
    - min_length: 50ms
      max_length: 350ms
      then:
          - light.toggle: light.garage_lights 

Turns out that if you want to control a light that exists in Home Assistant, there are a couple of ways to do that but I think the easiest way is to set up an automation in Home Assistant which reacts to the sensors you provide from that ESPHome device

Have a look here, you can directly call ha services from esphome, ie, light.toggle

The indentation is wrong in the original

From the link you posted it would seem you need to first have

    on_click:
      - min_length: 50ms
        max_length: 350ms
        then:
          - homeassistant.service:
            service: light.toggle
            data:
              entity_id: light.garage_lights