services: Add irc-doorduino

This commit is contained in:
polyfloyd 2023-09-10 21:13:31 +02:00
parent 7eea8662da
commit 0e75ce25c5
4 changed files with 71 additions and 0 deletions

View file

@ -0,0 +1,24 @@
#!/bin/bash
# Managed by Ansible
set -eu
set -o pipefail
initial=1
mqtt-simple -h {{ mqtt_internal_host }} -t "bitlair/doorduino/+" |
while read line; do
topic=$(echo "$line" | cut -d' ' -f1 | sed "s/bitlair\/doorduino\///")
value=$(echo "$line" | cut -s -d' ' -f2-)
if [ $initial == 0 ] && [ $value != 0 ]; then
if [ $topic == "doorbell" ]; then
irc-say "DEURBEL! Open de deur beneden!"
elif [ $topic != "dooropen" ]; then
irc-say "Doorduino: $topic $value"
fi
fi
initial=0
done