From 7c6887eaaf812b63bab6c5e134f80a2ef36aeb31 Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Tue, 12 Jan 2021 16:58:31 +0000 Subject: works --- prometheus/usr/local/bin/make_habitable | 11 +++++++ prometheus/usr/local/bin/midnight_tidy | 15 +++++++++ prometheus/usr/local/bin/set_radiator_target | 47 ++++++++++++++++++++++++++++ prometheus/usr/local/bin/vent | 17 ++++++++++ 4 files changed, 90 insertions(+) create mode 100755 prometheus/usr/local/bin/make_habitable create mode 100755 prometheus/usr/local/bin/midnight_tidy create mode 100755 prometheus/usr/local/bin/set_radiator_target create mode 100755 prometheus/usr/local/bin/vent (limited to 'prometheus/usr') diff --git a/prometheus/usr/local/bin/make_habitable b/prometheus/usr/local/bin/make_habitable new file mode 100755 index 0000000..730d632 --- /dev/null +++ b/prometheus/usr/local/bin/make_habitable @@ -0,0 +1,11 @@ +#!/bin/sh +set -x + +for i in 2fl_main_radiator 2fl_stair_radiator bathroom_radiator; do + /usr/local/bin/set_radiator_target $i 20 +done + + +for i in hall_radiator kitchen_radiator laundry_radiator kstudy_radiator bedroom_radiator ; do + set_radiator_target $i 18 +done diff --git a/prometheus/usr/local/bin/midnight_tidy b/prometheus/usr/local/bin/midnight_tidy new file mode 100755 index 0000000..2e6686e --- /dev/null +++ b/prometheus/usr/local/bin/midnight_tidy @@ -0,0 +1,15 @@ +#!/bin/sh +set -x + +/usr/local/bin/vent close + +for i in 2fl_main_radiator 2fl_stair_radiator bathroom_radiator bedroom_radiator hall_radiator kitchen_radiator kstudy_radiator laundry_radiator spare_bedroom_radiator; do + /usr/local/bin/set_radiator_target $i 10 +done + +for i in kitchen_left/POWER kitchen_right/POWER bathroom/POWER1 bathroom/POWER2 front_door/POWER 2ndfl_3gang_switch/POWER1 2ndfl_3gang_switch/POWER2 2ndfl_3gang_switch/POWER3; do + mosquitto_pub -h 127.0.0.1 -t cmnd/$i -m 0 + sleep 1 +done + + 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 + + + + diff --git a/prometheus/usr/local/bin/vent b/prometheus/usr/local/bin/vent new file mode 100755 index 0000000..28e5ad4 --- /dev/null +++ b/prometheus/usr/local/bin/vent @@ -0,0 +1,17 @@ +#!/bin/sh + +case "$1" in + open) + mosquitto_pub -h 10.32.135.1 -t cmnd/vent/POWER2 -m 1 + sleep 20 + mosquitto_pub -h 10.32.135.1 -t cmnd/vent/POWER2 -m 0 + ;; + close) + mosquitto_pub -h 10.32.135.1 -t cmnd/vent/POWER1 -m 1 + sleep 20 + mosquitto_pub -h 10.32.135.1 -t cmnd/vent/POWER1 -m 0 + ;; + *) + echo unknown command + ;; +esac -- cgit v1.2.3