Sonoff basic button not working

Hey folks,

I have an issue that is driving me nuts. I am trying to setup 3x gen 1 sonoff basics for some lamps and cannot get the button to also trigger the relay.

Here is the code I have:

binary_sensor:
  #Button press
  - platform: gpio
    name: "${devicename} Button"
    id: button_1
    pin:
      number: GPIO0
      mode:
        input: true
        pullup: true
      inverted: true
    internal: true
    on_press:
      - light.toggle: light_1

#setup relay 
output:
  - platform: gpio
    pin: GPIO12
    id: relay_1

#make it look like a light switch/bulb
light:
  - platform: binary
    name: "${devicename} Light"
    icon: "mdi:lightbulb"
    id: light_1
    output: relay_1

But its not working and I cant get my head round why. Any suggestions?

Thanks

J

This code i have works:

binary_sensor: # --------------------------------------------------------------- BINARY SENSORs
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "${devicename} Button"
    on_press:
      - switch.toggle: ${devicename}_relay

or, in your case:

    on_press:
      - light.toggle: light_1

The thing is you don’t have a relay (or switch) to toggle but configured your output (in hardware speak thats your relay) as a light :bulb:

So what you want to do is toggle your light like Pavel described:

Hi guys,

Thanks for the responses.

Maybe I am missing something but my code already toggles the light I have defined.

I followed the light component guide to get this far.

J