Initial commit
This commit is contained in:
commit
10c570b552
30
lol-opener.sh
Executable file
30
lol-opener.sh
Executable 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
|
Loading…
x
Reference in New Issue
Block a user