summaryrefslogtreecommitdiffstats
path: root/tasmota-config/configure-radiators
blob: b8e15a4ef25ae0fa02b61429a31e52939f07afbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
# Override is in var3
# we store current relay state in var4
# and use var5 for computing delta

# Timer1 is used as a WDT incase sensor fails
#

M=10.32.139.1


set -x

for T in laundry_radiator kstudy_radiator bedroom_radiator spare_bedroom_radiator music_room_e_radiator; do
  mosquitto_pub -h "${M}" -t "cmnd/${T}/Backlog" -m "Switchmode1 3; 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"
  sleep 3
  mosquitto_pub -h "${M}" -t "cmnd/${T}/Backlog" -m "Setoption36 0; Setoption65 1; Setoption1 1; SensorRetain 1; PowerRetain 1"
  sleep 3

##

  read -r -d '' R << EOF
    ON system#boot DO Backlog RuleTimer1 70; var1 5; var2 5; var3 0; var4 0 ENDON 
    ON Rules#Timer=1 DO Backlog RuleTimer1 70; Power %var3% ENDON 
    ON tele-SI7021#temperature DO Backlog RuleTimer1 70; Event temp=%value% ENDON 
    ON Button1#State DO event toggle3=%var3% ENDON
    ON Button2#State DO event toggle3=%var3% ENDON
EOF
  R="$(echo $R)"

  mosquitto_pub -h "${M}" -t "cmnd/${T}/Rule1" -m "${R}"
  sleep 5

##

  read -r -d '' R << EOF
    ON event#toggle3<1 DO BackLog var3 1; RuleTimer2 1800; Event temp=100 ENDON 
    ON event#toggle3>0 DO BackLog var3 0; RuleTimer2 0; Event temp=100 ENDON 
    ON Rules#Timer=2 DO var3 0 ENDON 
    ON Power1#State DO BackLog Var4 %value%; Publish2 stat/${T}/OPEN %value% ENDON
    ON Event#temp DO BackLog Publish2 stat/${T}/var1 %var1%; Publish2 stat/${T}/var2 %var2% ENDON
EOF
  R="$(echo $R)"

  mosquitto_pub -h "${M}" -t "cmnd/${T}/Rule2" -m "${R}"
  sleep 5
  
##

  read -r -d '' R << EOF
    ON Event#temp<%var1% DO Power1 1 ENDON
    ON Event#temp>%var2% DO Power1 %var3% ENDON
    ON Event#temp<5 DO Power1 1 ENDON
    ON Event#temp DO BackLog Var5 %var1%; Sub5 %value%; Publish2 stat/${T}/DELTA %var5%; Publish2 stat/${T}/OPEN %var4%; Publish2 stat/${T}/TEMPERATURE %value% 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"

done