diff options
-rwxr-xr-x | boiler-monster/mr3020/usr/bin/thermostat | 2 | ||||
-rwxr-xr-x | heating-cgi/heating.cgi | 20 | ||||
-rwxr-xr-x | mqtt_dash.sh | 190 | ||||
-rwxr-xr-x | prometheus/usr/local/bin/midnight_tidy | 15 | ||||
-rwxr-xr-x | prometheus/usr/local/bin/radiators_off | 4 | ||||
-rwxr-xr-x | prometheus/usr/local/bin/vents_close | 3 | ||||
-rw-r--r-- | radiator-plc/stm32/app/logic.c | 9 | ||||
-rwxr-xr-x | tasmota-config/configure-radiators | 3 |
8 files changed, 219 insertions, 27 deletions
diff --git a/boiler-monster/mr3020/usr/bin/thermostat b/boiler-monster/mr3020/usr/bin/thermostat index 8fcc071..612c899 100755 --- a/boiler-monster/mr3020/usr/bin/thermostat +++ b/boiler-monster/mr3020/usr/bin/thermostat @@ -46,7 +46,7 @@ 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 2fl_stair_radiator 2fl_main_radiator; do +for i in kstudy_radiator bedroom_radiator spare_bedroom_radiator dd_radiator1 dd_radiator2 dd_radiator3 hall_radiator kitchen_radiator music_room_radiator 2fl_stair_radiator 2fl_main_radiator boxroom_radiator; do O="$(mosquitto_sub -t stat/$i/OPEN -h ${M} -W 1 -C 1)" P="$(mosquitto_sub -t stat/$i/POWER -h ${M} -W 1 -C 1)" diff --git a/heating-cgi/heating.cgi b/heating-cgi/heating.cgi index 496f7ba..6d36f4d 100755 --- a/heating-cgi/heating.cgi +++ b/heating-cgi/heating.cgi @@ -615,16 +615,16 @@ sub do_boiler($) { . "' >", $pump, "</td></tr>\n"; -# my $dhw = $boiler->{0.2}->{values}->[0]; -# my $dhw_colour = '#c0c0ff'; -# $dhw_colour = '#ffc0c0' if $dhw == 1; - -# print "<tr><td><a href='" -# . $url -# . "boiler_dhw_active_boilermonster.html'>DHW running:</a></td><td style='background-color: " -# . $dhw_colour -# . "' >", $dhw, -# "</td></tr>\n"; + my $dhw = $boiler->{0.2}->{values}->[0]; + my $dhw_colour = '#c0c0ff'; + $dhw_colour = '#ffc0c0' if $dhw == 1; + + print "<tr><td><a href='" + . $url + . "boiler_dhw_active_boilermonster.html'>DHW running:</a></td><td style='background-color: " + . $dhw_colour + . "' >", $dhw, + "</td></tr>\n"; print "<tr><td><a href='" . $url diff --git a/mqtt_dash.sh b/mqtt_dash.sh new file mode 100755 index 0000000..e0378bc --- /dev/null +++ b/mqtt_dash.sh @@ -0,0 +1,190 @@ +#!/bin/bash + +id=1 + +TMP=/tmp/metrics.$$ + +( + + +color() +{ +guid=$(uuidgen) +echo " + { + \"enableIntermediateState\": true, + \"enablePub\": true, + \"enteredIntermediateStateAt\": 0, + \"format\": 0, + \"icon\": \"ic_radio_button_checked\", + \"id\": \"$guid\", + \"intermediateStateTimeout\": 0, + \"jsBlinkExpression\": \"\", + \"jsOnDisplay\": \"\", + \"jsOnReceive\": \"\", + \"jsOnTap\": \"\", + \"jsonPath\": \"\", + \"longId\": $id, + \"name\": \"$1\", + \"qos\": 0, + \"retained\": false, + \"topic\": \"$2\", + \"topicPub\": \"\", + \"type\": 6, + \"updateLastPayloadOnPub\": true + } +" +id=$[ $id + 1] +} + + +list() { +guid=$(uuidgen) +echo " + { + \"enableIntermediateState\": true, + \"enablePub\": true, + \"enteredIntermediateStateAt\": 0, + \"id\": \"$guid\", + \"intermediateStateTimeout\": 0, + \"items\": [ +" +echo "$3" + +echo " + ], + \"jsBlinkExpression\": \"\", + \"jsOnDisplay\": \"\", + \"jsOnReceive\": \"\", + \"jsOnTap\": \"\", + \"jsonPath\": \"\", + \"longId\": $id, + \"mainTextSize\": \"LARGE\", + \"name\": \"$1\", + \"qos\": 0, + \"retained\": false, + \"textColor\": -1, + \"topic\": \"$2\", + \"topicPub\": \"\", + \"type\": 4, + \"updateLastPayloadOnPub\": true + } +" + +id=$[ $id + 1] +} + +toggle() +{ +guid=$(uuidgen) +echo " + { + \"enableIntermediateState\": true, + \"enablePub\": $4, + \"enteredIntermediateStateAt\": 0, + \"iconOff\": \"ic_check_box_unchecked\", + \"iconOn\": \"ic_check_box_checked\", + \"id\": \"$guid\", + \"intermediateStateTimeout\": 0, + \"jsBlinkExpression\": \"\", + \"jsOnDisplay\": \"\", + \"jsOnReceive\": \"\", + \"jsOnTap\": \"\", + \"jsonPath\": \"\", + \"longId\": $id, + \"name\": \"$1\", + \"offColor\": -1, + \"onColor\": -1, + \"payloadOff\": \"$5\", + \"payloadOn\": \"$6\", + \"qos\": 0, + \"retained\": false, + \"topic\": \"$3\", + \"topicPub\": \"$2\", + \"type\": 2, + \"updateLastPayloadOnPub\": true + } +" +id=$[ $id + 1] +} + +numeric() { +guid=$(uuidgen) +echo " + { + \"decimalPrecision\": 1, + \"displayPayloadValue\": true, + \"enableIntermediateState\": false, + \"enablePub\": $4, + \"id\": \"$guid\", + \"intermediateStateTimeout\": 0, + \"jsBlinkExpression\": \"\", + \"jsOnDisplay\": \"\", + \"jsOnReceive\": \"\", + \"jsOnTap\": \"\", + \"jsonPath\": \"\", + \"longId\": $id, + \"maxValue\": $6, + \"minValue\": $5, + \"name\": \"$1\", + \"postfix\": \"\", + \"prefix\": \"\", + \"progressColor\": -1, + \"qos\": 0, + \"retained\": false, + \"topic\": \"$3\", + \"topicPub\": \"$2\", + \"type\": 3, + \"updateLastPayloadOnPub\": true + } + +" +id=$[ $id + 1] +} + + +lightswitch() { +toggle $1 cmnd/$2/$3 stat/$2/$3 true OFF ON +} + +lightswitch_l() { +lightswitch $1 $1 POWER +} + +radiator() { +toggle "${1}_coil" cmnd/$1/POWER stat/$1/POWER false OFF ON +echo "," +toggle "${1}_open" cmnd/$1/OPEN stat/$1/OPEN false 0 1 +echo "," +numeric "${1}_temp" cmnd/$1/TEMPERATURE stat/$1/TEMPERATURE false 5.0 35.0 +echo "," +numeric "${1}_low" cmnd/$1/var1 stat/$1/var1 true 5.0 35.0 +echo "," +numeric "${1}_high" cmnd/$1/var2 stat/$1/var2 true 5.0 35.0 +} + + + +echo "[" + + +for r in hall_radiator laundry_radiator kitchen_radiator dd_radiator1 dd_radiator2 dd_radiator3 music_room_radiator music_room_e_radiator plc0_radiator7; do +radiator $r +echo "," +done + +for r in bathroom_radiator bedroom_radiator kstudy_radiator boxroom_radiator spare_bedroom_radiator ; do +radiator $r +echo "," +done + +radiator 2fl_main_radiator +echo "," +radiator 2fl_stair_radiator + +echo "]" + + +) > ${TMP} + +mosquitto_pub -h 10.32.137.1 -t metrics/exchange -f ${TMP} diff --git a/prometheus/usr/local/bin/midnight_tidy b/prometheus/usr/local/bin/midnight_tidy deleted file mode 100755 index 27400dd..0000000 --- a/prometheus/usr/local/bin/midnight_tidy +++ /dev/null @@ -1,15 +0,0 @@ -#!/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 dd_radiator1 dd_radiator2 dd_radiator3 ; 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/radiators_off b/prometheus/usr/local/bin/radiators_off new file mode 100755 index 0000000..40c6fea --- /dev/null +++ b/prometheus/usr/local/bin/radiators_off @@ -0,0 +1,4 @@ +#!/bin/sh +for i in 2fl_main_radiator 2fl_stair_radiator bathroom_radiator bedroom_radiator hall_radiator kitchen_radiator kstudy_radiator laundry_radiator spare_bedroom_radiator dd_radiator1 dd_radiator2 dd_radiator3 ; do + /usr/local/bin/set_radiator_target $i 10 +done diff --git a/prometheus/usr/local/bin/vents_close b/prometheus/usr/local/bin/vents_close new file mode 100755 index 0000000..5562ca9 --- /dev/null +++ b/prometheus/usr/local/bin/vents_close @@ -0,0 +1,3 @@ +#!/bin/sh +/usr/local/bin/vent close + diff --git a/radiator-plc/stm32/app/logic.c b/radiator-plc/stm32/app/logic.c index b5b768d..fb6ccd4 100644 --- a/radiator-plc/stm32/app/logic.c +++ b/radiator-plc/stm32/app/logic.c @@ -96,6 +96,8 @@ int high_limit[N_VALVES] = { 00000, }; +int override[N_VALVES]; + int valve_state[N_VALVES]; int failed_reads[N_VALVES]; @@ -130,6 +132,10 @@ void mqtt_dispatch (char *type, char *who, char *what, char *msg) usart1_queue_buf (msg_buf, sprintf (msg_buf, "\r\nMQTTR stat/%s/var2 %.2f\r\n", valve_name[i], scale (high_limit[i]))); } + if (!strcmp (what, "var3")) { + override[i] = atoi (msg); + usart1_queue_buf (msg_buf, sprintf (msg_buf, "\r\nMQTTR stat/%s/var3 %d\r\n", valve_name[i], override[i])); + } } } @@ -164,6 +170,9 @@ void logic_tick (void) valve_state[i] = 0; } + if (override[i]) + valve_state[i]=1; + o = valve_state[i]; output_write (i, o); diff --git a/tasmota-config/configure-radiators b/tasmota-config/configure-radiators index b8e15a4..18ba8e5 100755 --- a/tasmota-config/configure-radiators +++ b/tasmota-config/configure-radiators @@ -18,7 +18,8 @@ M=10.32.139.1 set -x -for T in laundry_radiator kstudy_radiator bedroom_radiator spare_bedroom_radiator music_room_e_radiator; do +#for T in laundry_radiator kstudy_radiator bedroom_radiator spare_bedroom_radiator music_room_e_radiator boxroom_radiator; do +for T in boxroom_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" |