Make a Binary sensor from a Switch Output (How do I)

The code below worked and validated before the June 2024 update

Now it is saying that I have used GPIO12 twice

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO10
      mode:
        input: true
        pullup: true
      inverted: true
    name: "Heating Button"
    on_press:
      - switch.toggle: relaydown

  - platform: gpio
    name: "Relay Heating Downstairs status" 
    pin: GPIO12
    
    
switch:
  - platform: gpio
    pin: GPIO12
    id: relaydown

How can I now used GPIO12 to show as a Binary Sensor on my dashboard and in my automations?

Regards, Dave

I don’t know why you need that, but if so, try with template binary sensor

Thanks, will give that a try.

i wanted the status of the output to be shown, but did not want it to have a toggle switch next to it.

Ahh, ok. Esthetic reasons… :grinning:
Go with template.

Looks like you’re accidentally using GPIO12 twice in your configuration. ESPHome won’t allow that. You can simply remove the pin definition for the binary sensor using GPIO12 and it should work!

ESPHome will allow using the same pin if you set allow_other_uses to true in the pin schema.

However the best solution is probably to use a template binary sensor reflecting the state of the switch.