Initial commit

This commit is contained in:
EpicKiwi 2025-01-07 21:02:33 +01:00
commit 10c570b552
Signed by: epickiwi
GPG Key ID: C4B28FD2729941CE

30
lol-opener.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
function isClosed {
mosquitto_sub -t zigbee/entree -h mosquitto.labolyon.dn42 -C 1 | jq ".contact"
}
function waitForEvent {
mosquitto_sub -t zigbee/entree -h mosquitto.labolyon.dn42 -C 2 | tail +2 | jq ".contact"
}
while $(true); do
state=$(waitForEvent)
if [[ "$state" = "false" ]]; then
echo "Porte ouverte, 30 secondes avant l'ouverture du local"
sleep 3
if [[ "$(isClosed)" = "false" ]]; then
systemctl start lol-opening.service
fi
else
echo "Porte fermee, 10 secondes avant la fermeture du local"
sleep 1
if [[ "$(isClosed)" = "true" ]]; then
systemctl stop lol-opening.service
fi
fi
done