Rpi_gpio freezes the value of binary_sensor

baseboard: raspberry 3 b+
OS: Linux raspberrypi 4.19.108-v7+ #1298

#./configuration.yaml

default_config:

tts:

  • platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

lovelace:
mode: yaml

binary_sensor:

  • platform: rpi_gpio
    invert_logic: true
    pull_mode: UP
    bouncetime: 50
    ports:
    17: button

#ui-lovelace.yaml

title: home assistant
views:

  • title: Кнопка
    icon: mdi:gesture-tap-button
    cards:
    • type: button
      entity: binary_sensor.button

when you press the button repeatedly, the value hangs in the “on” state, while the “off” button.

if you run the code

#!/usr/bin/python3.7
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin, GPIO.IN)
try:
while True:
print(GPIO.input(17))
except KeyboardInterrupt:
pass
except:
print(“except”)
finally:
GPIO.cleanup()

here are no freezes

what am I doing wrong?