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.