summaryrefslogtreecommitdiffstats
path: root/tasmota-config/configure-humidifier
diff options
context:
space:
mode:
Diffstat (limited to 'tasmota-config/configure-humidifier')
-rwxr-xr-xtasmota-config/configure-humidifier74
1 files changed, 74 insertions, 0 deletions
diff --git a/tasmota-config/configure-humidifier b/tasmota-config/configure-humidifier
new file mode 100755
index 0000000..029c860
--- /dev/null
+++ b/tasmota-config/configure-humidifier
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+# Adapted from https://tasmota.github.io/docs/Rules/#simple-thermostat-example
+
+# Button give 30 mins of hot.
+
+# Low setpoint is var1
+# High setpoint is var2
+# Have water in var3
+
+# Timer1 is used as a WDT incase sensor fails
+#
+
+M=10.32.139.1
+
+
+set -x
+
+T=music_room_humidifier
+
+mosquitto_pub -h "${M}" -t "cmnd/${T}/Backlog" -m "Rule1 1; Rule1 4; Rule2 1; Rule2 4; Rule3 1; Rule3 4"
+sleep 3
+mosquitto_pub -h "${M}" -t "cmnd/${T}/Backlog" -m "TelePeriod 60; SetOption26 0; SetOption0 0; PowerOnState 0; switchmode2 1"
+sleep 3
+mosquitto_pub -h "${M}" -t "cmnd/${T}/Backlog" -m "Setoption36 0; Setoption65 1; Setoption1 1; SensorRetain 1; PowerRetain 1"
+sleep 3
+mosquitto_pub -h "${M}" -t "cmnd/${T}/Backlog" -m "SwitchMode1 0;SwitchMode2 1; SetOption63 1; LedMask 2"
+sleep 3
+
+
+
+## timer 1 turns off if we lose contact with sensor
+## publish a humid event on humidity data
+
+read -r -d '' R << EOF
+ ON system#boot DO Backlog RuleTimer1 70; var1 48; var2 53; ENDON
+ ON Rules#Timer=1 DO Backlog RuleTimer1 70; Power1 0 ENDON
+ ON tele-SI7021#humidity DO Backlog RuleTimer1 70; Event humid=%value% ENDON
+EOF
+R="$(echo $R)"
+
+mosquitto_pub -h "${M}" -t "cmnd/${T}/Rule1" -m "${R}"
+sleep 5
+
+## publish setpoints on humidity data
+
+read -r -d '' R << EOF
+ ON Event#humid DO BackLog Publish2 stat/${T}/var1 %var1%; Publish2 stat/${T}/var2 %var2%; Publish2 stat/${T}/var3 %var3% ENDON
+ ON Switch2#state=0 DO BackLog var3 0; Power1 0 ENDON
+ ON Switch2#state=1 DO var3 1 ENDON
+EOF
+R="$(echo $R)"
+
+mosquitto_pub -h "${M}" -t "cmnd/${T}/Rule2" -m "${R}"
+sleep 5
+
+##
+
+read -r -d '' R << EOF
+ ON Event#humid<%var1% DO Power1 %var3% ENDON
+ ON Event#humid>%var2% DO Power1 0 ENDON
+EOF
+R="$(echo $R)"
+
+mosquitto_pub -h "${M}" -t "cmnd/${T}/Rule3" -m "${R}"
+sleep 5
+
+#
+
+mosquitto_pub -h "${M}" -t "cmnd/${T}/Restart" -m "1"
+
+
+exit 0
+