summaryrefslogtreecommitdiffstats
path: root/boiler-monster/mr3020/usr
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2020-09-09 11:53:37 +0100
committerfishsoupisgood <github@madingley.org>2020-09-09 11:53:37 +0100
commit9d87c925a9eaa4fc256be3173c14a20d1469472d (patch)
tree50d63f87a47a0eac3f5b8058850184bcd4e6ee95 /boiler-monster/mr3020/usr
parentdafd8cf2fdcdd637cc06f760d318cf8391b1a294 (diff)
downloadheating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.gz
heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.bz2
heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.zip
everything, mostly, working
Diffstat (limited to 'boiler-monster/mr3020/usr')
-rwxr-xr-xboiler-monster/mr3020/usr/bin/thermostat70
1 files changed, 70 insertions, 0 deletions
diff --git a/boiler-monster/mr3020/usr/bin/thermostat b/boiler-monster/mr3020/usr/bin/thermostat
new file mode 100755
index 0000000..1689964
--- /dev/null
+++ b/boiler-monster/mr3020/usr/bin/thermostat
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+LOCK=/var/lock/LCK..ttyATH0
+M=10.32.139.1
+
+WATERS=0
+MAX=70
+
+# conventions
+# POWER is power to valve coil
+# OPEN is valve state
+# DELTA is temp difference
+# var1 is low set point
+# var2 is high set point
+# var3 is manual override
+
+# towel radiators
+
+for i in laundry_radiator bathroom_radiator; do
+ O="$(mosquitto_sub -t stat/$i/OPEN -h ${M} -W 1 -C 1)"
+
+ W=0
+ if [ "$O" == "1" ]; then
+ W=$MAX
+ fi
+ WATERS="$WATERS $W"
+
+ logger -t thermostat " $i O=$O W=$W"
+done
+
+#... others where we care about the delta
+
+for i in kstudy_radiator bedroom_radiator spare_bedroom_radiator dd_radiator1 dd_radiator2 dd_radiator3 hall_radiator kitchen_radiator music_room_radiator; do
+ O="$(mosquitto_sub -t stat/$i/OPEN -h ${M} -W 1 -C 1)"
+ D="$(mosquitto_sub -t stat/$i/DELTA -h ${M} -W 1 -C 1 | sed -e 's/\..*$//g') "
+
+ W=0
+ if [ "$O" == "1" ]; then
+ W=$[ $D * 3 + 40]
+ fi
+
+ logger -t thermostat " $i O=$O D=$D W=$W"
+
+ WATERS="$WATERS $W"
+done
+
+
+R=0
+for w in ${WATERS}; do
+ if [ $w -gt $R ]; then
+ R=$w
+ fi
+done
+
+if [ $R -gt $MAX ]; then
+ R=$MAX
+fi
+
+
+
+
+if [ ! -f "${LOCK}" ]; then
+ logger -t thermostat "Requesting water temp of $R"
+ printf "\nCH=%d\n" $R > /dev/ttyATH0
+else
+ logger -t thermostat "Interface is locked, so cant request water temp of $R"
+fi
+
+
+