I have a dehumidifier that I want to control from Home Assistant while still being able to use the buttons. For instance if I turn it on/off it should show on/off in Home Assistant and vice versa. I soldered two leads to the button and hooked it up to my d1 mini
Correct. Can’t use same pin for both. What you’re asking to do is quite complicated. Without knowing some very specific electronic details of your dehumidifier, My suggestions are going to be pretty abstract:
For control, use a relay with contacts connected to either side of the dehumidifier power button (assuming it is a momentary button). This electrically isolates esphome from the dehumidifier circuitry - which you definitely want.
For detection, I’d setup something similarly isolated. Maybe a LDR places next to the dehumidifier power LED that esphome can use to detect if power LED is on.
You need to have the switch output of your D1mini connected across the switch contact of the dehumidifier and then use a separate input pin on the D1mini to read the status from the dehumidifier to give you the binary sensor. You should be able to get the status from somewhere on that circuit board (I was hoping to see a generic ‘ON’ LED but dont see that…)
What voltage is the dehumidifier circuit board running? You may need to do all of this using:
a relay on the D1mini output to simulate the button press
a voltage divider resistor circuit to take the status back to the D1mini
That circuit is likely also just reading the state of the button, therefore it isn’t putting out any on/off signal on that node. So your idea requires a second wire, if you will, to get the on/off state from the circuit.
As mentioned above, LED’s are a good target for getting a binary signal, since they are always safe low voltage. Other parts of that circuit may carry mains voltage… stay away from probing parts that look dangerous (thicker traces, bulky caps and transformers, isolation slots, etc…). Usually parts attached to thin and closely spaced pcb traces are safe to probe. Either way, some probing needs to be done to find a suitable on/off signal.
A relay is likely needed to operate the button. That’s the second wire. If your really, I mean really really, can’t use a second pin, you’ll have to DIY some rather complicated 1-wire method… and that’s a far stretch for DIY… certainly not something you’ll get a schematic for by asking here.
Thanks everyone. Unfortunately, there is no simple on/off led just the digit display. I’m going to try looking at the connector for on/off signal with a multimeter.