ESPHome binary sensor - always shows as ON


Using a Wemos D1 mini with HA and ESPHome (latest versions).

I am using a 3v input to identify a PC being On or Off. Unfortunately, it always shows as ON, even with the wire disconnected from the input pin. Any ideas? The ground is common between the 5V ESP power source and my 3v input. I have confirmed my 3v input is changing as expected (3v with the PC On, 0v with the PC Off). I have tried a second Wemos D1 mini with the same results.

I must be missing something :slight_smile: Thanks for any help!

  - platform: gpio
    pin:  GPIO4      #D2   # Power detect input pin
    name: "PC Power State"
    device_class: power

What happens if you short the GPIO4 to GND?

1 Like

Shorting GPIO4 to GND does then show as Off.

My mistake in testing - I was just disconnecting from the GPIO and leaving it floating - if I actually turn off the PC it shows as Off as my voltage divider pulls the GPIO to ground…

Thank you for pointing me in the right direction!

1 Like

If so, I suggest you use an optical coupler。