How I finally got door status working on my CYD - steps that actually worked

Oct 22, 2026 Last reply: 6 hours ago 4 Replies

First reply

PlumbRunner_1963

My biggest hurdle was definatly figuring out the right distance for the sensor and magnet placement. I used the reed switch paired with a generic ESP32 board and it took me nearly two days to get it working reliably on the old shed door. I initially had them mounted right next…

Read the full reply

Spent a frustrating weekend getting door open/closed showing on my CYD dashboard, so here's what worked in case it saves someone the headache. First thing: don't bother with the pins on the back header you'd expect to use. Most of them are alredy tied up driving the screen. The free ones are on the side, and one of them only works as an input, wich is fine because a magnetic door switch is exactly that. I wired one lead to the input pin and the other to ground, then set the pin with a pullup in the yaml so it reads high when the magnet's away and low when the door shuts.



Second thing I wish I'd known earlier: test the sensor with a multimeter or just the ESPHome logs before you mount anything. I stuck my reed switch on the frame first, then spent an hour wondering why the state never flipped. Turns out the magnet in my door handle was close enough to confuse it. Moved the sensor two inches down and it's been rock solid since. Last tip, flip the invert option in ESPHome rather than rewiring if your open/closed states come out backwards. Obvious in hindsight, not so much at midnight.


My biggest hurdle was definatly figuring out the right distance for the sensor and magnet placement. I used the reed switch paired with a generic ESP32 board and it took me nearly two days to get it working reliably on the old shed door. I initially had them mounted right next to the frame, but the signal kept jumping around when the door was slightly ajar, maybe less than an inch. It was too sensitive to minor vibrations. I ended up mounting the magnet about three inches away from the sensor itself, centered on the latch area. That distance gave enough separation so that when the door was fully closed and the latch was secured, the switch held a solid state. If I kept them too close, the proximity of the metal frame seemed to interfere with the magnetic field enough to cause spurious readings. I also ran into a minor issue where the state reporting felt sluggish when the door was moving quickly. I ended up adding a short debounce setting in the configuration file. It seemed like that tiny delay helped the readings stabilize during the transition, making the dashboard update reliably even if I swung the door open fast. It’s all about finding that sweet spot between sensitivity and noise reduction!

Good call on the side header. One thing to add for anyone wiring this up: on my unit the input-only pin doesn't actually have a working internal pullup, so the yaml pullup option did nothing and the pin floated all over the place. Soldered a 10k resistor from the pin to 3.3V and the state went from flickering every few seconds to completely stable. Worth checking the logs before assuming the switch itself is bad.

I tried this setup on a pantry door that is just wood and plastic, not metal like the shed door you mentioned. The sensor was still giving really jumpy readings even when the door was fully shut. I spent ages troubleshooting the settings, but I think the material of the door itself might be causing the problem. Does the type of material the door and frame are made of really change how well the magnetic switch reads the signal?

Quick update - the door status issue is solved. It turned out that the input pin didn't have a usable internal pullup, exactly as one person pointed out. Soldering the external resistor got rid of the floating readings and the state is rock solid now.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required