Gpio debounce issue

I’m using the gpio binary sensor component with some magnetic window switches.

binary_sensor:

  • platform: rpi_gpio
    ports:
    17: Bedroom

The problem is that you have to open the window sharp/smooth, especially while the magnet is near the switch. If there is a split second pause or jerk in your motion, the input seems to bounce and stick. A close/reopen seems to reset the state. If I turn the debounce time to 1 (off I think), it doesn’t seem to stick, but the state change is very jittery. I suppose I off is the lesser of evils, but I’m a bit OCD and I wonder if that would mess with automations.

I’m wondering if the resistor values I’m using are causing an issue. I opted for the following circuit example as it was the only way to get a state change to register somewhat consistently:

schem

I guess my question is, does anyone have a recommended resistor value/debounce time, particularly in regards to door/window sensors? Before I go trying random values I figured I could ask :slight_smile:

Apologies for the code formatting. Still trying to figure out this site. I’m pretty new here.

binary_sensor:
  - platform: rpi_gpio
    ports:
      17: Bedroom