Small Raspberry Pi python application that sends "OPEN" or "CLOSED" state of a magnet sensor to an openHAB Contact Item according to the settings in .env.
Please be aware that in my setup the magnet sensor has no contact in the default position and is OPEN/"active" when the flap swings so that there is a short contact at the sensor.
Therefore you maybe have to switch the state values in the .env file according to your setup.
- Install git and pip3
sudo apt-get update && sudo apt-get install git python3-pip -y- Clone the Repo
git clone https://github.com/DarkC35/catflap-magnet
cd catflap-magnet- Install requirements
sudo pip3 install -r requirements.txt- Set required env values
cp .env.sample .env
nano .envOPENHAB_THING_STATE_URL=http://<openhab-host>:<openhab-port>/rest/items/<contact-item-name>/state
MAGNET_PIN=<gpio-pin-number>
ACTIVATED_STATE=OPEN
DEACTIVATED_STATE=CLOSED- Install system unit
# chmod +x install.sh
./install.sh