If you want to read the status of a GPIO input port use the following Python script.
The next Python script is reading the status of the GPIO PIN 22 on a 0/1 value and will print "closed"or "OPEN".
I use this script to read the status of the garage door.
---------------------------------------------------------------
#!/usr/bin/python3
import gpiod
PI_PIN = 22
GPIOCHIPSET = "/dev/gpiochip0"
GPIOLINE=gpiod.request_lines(GPIOCHIPSET,consumer="gdoorget",config={
PI_PIN: gpiod.LineSettings(
direction=gpiod.line.Direction.INPUT,bias=gpiod.line.Bias.PULL_UP)
})
INTEST=GPIOLINE.get_value(PI_PIN)
CHECK=str(INTEST)
if CHECK == "Value.INACTIVE":
print("OPEN", end='')
else:
print("dicht", end='')
GPIOLINE.release()
exit()
-------------------------------------------------------------------------------------------------------------