From 4560c3d1250f0392ebbdde25ff72053046d72da5 Mon Sep 17 00:00:00 2001 From: James <31272717+gpd-pocket-hacker@users.noreply.github.com> Date: Wed, 17 Feb 2021 18:33:59 +0000 Subject: better cgi --- heating-cgi/Makefile | 2 +- heating-cgi/heating.cgi | 56 +++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/heating-cgi/Makefile b/heating-cgi/Makefile index 7a7bc3b..3154015 100644 --- a/heating-cgi/Makefile +++ b/heating-cgi/Makefile @@ -5,7 +5,7 @@ SRC=heating.cgi boiler_rx run_boiler_rx other.stamp: ${SRC} - scp heating.cgi other:/export/home/httpd/heating/cgi-bin/index.cgi + #scp heating.cgi other:/export/home/httpd/heating/cgi-bin/index.cgi scp boiler_rx run_boiler_rx other:/usr/local/sbin/ touch $@ diff --git a/heating-cgi/heating.cgi b/heating-cgi/heating.cgi index dd608b6..00afc52 100755 --- a/heating-cgi/heating.cgi +++ b/heating-cgi/heating.cgi @@ -6,8 +6,6 @@ use warnings; use Net::MQTT::Simple; use JSON::Parse; -use Data::Dumper; - use CGI qw/:standard :cgi-lib/; use CGI::Carp qw(fatalsToBrowser); @@ -554,13 +552,13 @@ sub do_radiators() { print "\n"; print -"\n"; +"\n"; for my $r ( sort( keys(%$mqtt_data) ) ) { my $rd = $mqtt_data->{$r}; print ""; print -""; print ""; @@ -603,7 +601,7 @@ sub do_boiler($) { return unless defined $boiler; my $url = -'http://munin.backdown.james.local/prometheus.james.local/boilermonster.prometheus.james.local/'; +'http://munin.ourano.james.local/prometheus.james.local/boilermonster.prometheus.james.local/'; print "
RadiatorsLowTempHighHumidDeltaValveSensorSet target
RadiatorsLowTempHighHumidDeltaValveSensorSet target
", $r, "", $rd->{var1}, "
\n"; print "\n"; @@ -652,6 +650,19 @@ sub do_boiler($) { print "
Boiler
\n"; } +sub make_preset($$) +{ +my ($here,$map)=@_; + +my @wot=(); +for my $k (keys %$map) { +push @wot,$k."=".$map->{$k} ; +} + +return $here."?".join('&',@wot); +} + + my $css = <<'EOF'; tr:nth-child(odd) td { background-color: #ffffff @@ -665,6 +676,39 @@ my $all_params = Vars(); my $here = $ENV{SCRIPT_NAME}; +my $off=10; + +my $all_off={ +'2fl_main_radiator' => $off, +'2fl_stair_radiator' => $off, +'bathroom_radiator' => $off, +'bedroom_radiator' => $off, +'dd_radiator1' => $off, +'dd_radiator2' => $off, +'dd_radiator3' => $off, +'hall_radiator' => $off, +'kitchen_radiator' => $off, +'kstudy_radiator' => $off, +'laundry_radiator' => $off, +'spare_bedroom_radiator' => $off +}; + + +my $attic_bathroom_ground_floor={ +'2fl_main_radiator' => 20, +'2fl_stair_radiator' =>20, +'bathroom_radiator' => 19, +'dd_radiator1' => 18, +'dd_radiator2' => 18, +'dd_radiator3' => 18, +'hall_radiator' => 18, +'kitchen_radiator' => 18, +'laundry_radiator' => 18 +}; + + + + print header( -type => 'text/html', -charset => 'utf-8', @@ -680,7 +724,7 @@ print start_form(); do_radiators(); print end_form(); -print "
Refresh
\n"; +print "
Refresh   Heat Attic, Bathroom and Ground floor   all off
\n"; if ( scalar( keys %$all_params ) > 0 ) { print "

Updates

\n"; -- cgit v1.2.3