diff options
author | James <31272717+gpd-pocket-hacker@users.noreply.github.com> | 2021-02-17 18:33:59 +0000 |
---|---|---|
committer | James <31272717+gpd-pocket-hacker@users.noreply.github.com> | 2021-02-17 18:34:08 +0000 |
commit | 4560c3d1250f0392ebbdde25ff72053046d72da5 (patch) | |
tree | 65f6496d1f002dc1d391846fca9a8bc250c216f5 /heating-cgi/heating.cgi | |
parent | c994c3323ee1b0d19faa86ebe26a01d566b86eaa (diff) | |
download | heating-4560c3d1250f0392ebbdde25ff72053046d72da5.tar.gz heating-4560c3d1250f0392ebbdde25ff72053046d72da5.tar.bz2 heating-4560c3d1250f0392ebbdde25ff72053046d72da5.zip |
better cgi
Diffstat (limited to 'heating-cgi/heating.cgi')
-rwxr-xr-x | heating-cgi/heating.cgi | 56 |
1 files changed, 50 insertions, 6 deletions
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 "<table>\n"; print -"<tr><th align=left><a href='http://munin.backdown.james.local/prometheus.james.local/prometheus.prometheus.james.local/index.html'>Radiators</a></th><th>Low</th><th>Temp</th><th>High</th><th>Humid</th><th>Delta</th><th>Valve</th><th>Sensor</th><th colspan=8 align=left>Set target</th></tr>\n"; +"<tr><th align=left><a href='http://munin.ourano.james.local/prometheus.james.local/prometheus.prometheus.james.local/index.html'>Radiators</a></th><th>Low</th><th>Temp</th><th>High</th><th>Humid</th><th>Delta</th><th>Valve</th><th>Sensor</th><th colspan=8 align=left>Set target</th></tr>\n"; for my $r ( sort( keys(%$mqtt_data) ) ) { my $rd = $mqtt_data->{$r}; print "<tr>"; print -"<td><a href='http://munin.backdown.james.local/prometheus.james.local/prometheus.prometheus.james.local/radiator_" +"<td><a href='http://munin.ourano.james.local/prometheus.james.local/prometheus.prometheus.james.local/radiator_" . $r . "_temp.html'>", $r, "</a></td>"; print "<td>", $rd->{var1}, "</td>"; @@ -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 "<table>\n"; print "<tr><th colspan=2 align=left><a href='" . $url . "index.html'>Boiler</a></th></tr>\n"; @@ -652,6 +650,19 @@ sub do_boiler($) { print "</table>\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 "<br/> <a href='" . $here . "'>Refresh</a></br>\n"; +print "<br/> <a href='" . $here . "'>Refresh</a> <a href='" . make_preset($here,$attic_bathroom_ground_floor). "'>Heat Attic, Bathroom and Ground floor</a> <a href='".make_preset($here,$all_off)."'>all off</a><br/>\n"; if ( scalar( keys %$all_params ) > 0 ) { print "<h2>Updates</h2>\n"; |