MQTT publish persistent status of reed switch connected to GPIO pin on a Raspberry Pi
Stratum 0 Space infrastructure.
This script runs on powerberry and checks the reed switch attached to the front door. When the door opens or closes, it publishes a persistent status with timestamp to the mqtt broker, currently nastratum. Pin 27 is connected to 3.3V via a pullup resistor
Script loosely adapted from https://gist.github.com/nickbalch/f926ad707828c0b73b7aa222c43a67e4
pip install paho-mqtt
As the open/close status of the door should not be of a very high frequency, the bouncetime value is set rather high