diff options
author | fishsoupisgood <github@madingley.org> | 2021-01-12 16:58:31 +0000 |
---|---|---|
committer | fishsoupisgood <github@madingley.org> | 2021-01-12 16:58:31 +0000 |
commit | 7c6887eaaf812b63bab6c5e134f80a2ef36aeb31 (patch) | |
tree | 4b4b0d371107ae1b8540ca1618cb9aa796b72616 /prometheus/usr/local/bin/set_radiator_target | |
parent | f4b573fe337a436d5e2b20be4be031d77376d609 (diff) | |
download | heating-7c6887eaaf812b63bab6c5e134f80a2ef36aeb31.tar.gz heating-7c6887eaaf812b63bab6c5e134f80a2ef36aeb31.tar.bz2 heating-7c6887eaaf812b63bab6c5e134f80a2ef36aeb31.zip |
works
Diffstat (limited to 'prometheus/usr/local/bin/set_radiator_target')
-rwxr-xr-x | prometheus/usr/local/bin/set_radiator_target | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/prometheus/usr/local/bin/set_radiator_target b/prometheus/usr/local/bin/set_radiator_target new file mode 100755 index 0000000..c52d22a --- /dev/null +++ b/prometheus/usr/local/bin/set_radiator_target @@ -0,0 +1,47 @@ +#!/bin/sh + +R=$1 +T1=$2 + + +case "$R" in + bathroom_radiator) + T2=$( expr $T1 + 2 ) + ;; + *) + T2=$( expr $T1 + 1 ) + ;; +esac + +H=127.0.0.1 + +for tries in 1 2 3 4 5 6 7 8 9 10 11 12; do + + V1=$( mosquitto_sub -h 10.32.139.1 -t stat/$R/var1 --retained-only -W 1 | sed -e 's/\..*//' ) + V2=$( mosquitto_sub -h 10.32.139.1 -t stat/$R/var2 --retained-only -W 1 | sed -e 's/\..*//' ) + + if [ $T1 -ne $V1 ]; then + mosquitto_pub -h $H -t cmnd/$R/var1 -m $T1 + sleep 1 + fi + + if [ $T2 -ne $V2 ]; then + mosquitto_pub -h $H -t cmnd/$R/var2 -m $T2 + sleep 1 + fi + + + if [ \( $T1 -eq $V1 \) -a \( $T2 -eq $V2 \) ]; then + echo Success + exit 0 + fi + + sleep 3 + +done + +echo Failed + + + + |