From 9b51ae6f7cd5c6e3f480d446a186a46a5bab8bfa Mon Sep 17 00:00:00 2001 From: root Date: Fri, 28 May 2021 19:47:21 +0100 Subject: fish --- boiler-monster/mr3020/usr/bin/thermostat | 29 ++++++++++++++++++++++++++++- heating-cgi/boiler_rx | 11 ++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/boiler-monster/mr3020/usr/bin/thermostat b/boiler-monster/mr3020/usr/bin/thermostat index 91e2e7b..8fcc071 100755 --- a/boiler-monster/mr3020/usr/bin/thermostat +++ b/boiler-monster/mr3020/usr/bin/thermostat @@ -20,8 +20,20 @@ logger -t thermostat " outside is $OUTSIDE" # towel radiators +FUZZY=0 + for i in laundry_radiator bathroom_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)" + + if [ "$P" == "OFF" -a "$O" == "1" ]; then + FUZZY=1 + O=0 + fi + + if [ "$P" == "ON" -a "$O" == "0" ]; then + FUZZY=1 + fi W=0 if [ "$O" == "1" ]; then @@ -36,6 +48,18 @@ done 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 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)" + + if [ "$P" == "OFF" -a "$O" == "1" ]; then + FUZZY=1 + O=0 + fi + + if [ "$P" == "ON" -a "$O" == "0" ]; then + FUZZY=1 + fi + + T="$(mosquitto_sub -t stat/$i/TEMPERATURE -h ${M} -W 1 -C 1 | sed -e 's/\..*$//g') " D="$(expr $T - $OUTSIDE)" @@ -63,7 +87,10 @@ if [ $R -gt $MAX ]; then R=$MAX fi - +if [ "$FUZZY" -eq 1 ]; then + logger -t thermostat "Fuzzy=1, stopping pump" + R=0 +fi if [ ! -f "${LOCK}" ]; then diff --git a/heating-cgi/boiler_rx b/heating-cgi/boiler_rx index 777b3ee..f794e1b 100755 --- a/heating-cgi/boiler_rx +++ b/heating-cgi/boiler_rx @@ -35,10 +35,19 @@ while (1) { my $nodata = 0; while ( ( not $telnet->eof ) and ( $nodata < $timeout ) ) { - my $line = $telnet->getline( Timeout => 1, Errmode => 'return' ); + my $line = undef; + eval { + local $SIG{ALRM} = sub { die 'Timed Out'; }; + alarm 2; + + $line = $telnet->getline( Timeout => 1, Errmode => 'return' ); + alarm 0; + }; + alarm 0; if ( not defined $line or ( length($line) == 0 ) ) { $nodata++; + next; } else { $nodata = 0; -- cgit v1.2.3