Heizungssteuerung Web-Interface
Web-Interface to interact with my HVC
Of course you need to run a web server on your RaspberryPi, to enable this feature.
The interaction between php and pyton in handled via files. On the one hand the log files of the control are read and the current values shown. On the other hand, configuration data is written to interact with the control.
In the first line a session has to be started to use cookies for loggin in.
main
The main function has two purposes:
- Pagelayout
With the strings $head and $foot the layout for all pages is centrally defined. - Pagecontent
What is shown is controlled via $what2do which indicates which functions should be executed by the switch-case structure.
If $what2do is not set, the default page with the overview sketch of the house is shown. In any other case it is checked first whether the user authentificated herself such that $_SESSION['IamGod'] is set - if not the user is redirected to the login.
HV_Admin_Login
Function to login/logoff the user.
Special feature is the increasing delay if someone should try to steal the password.
HV_showHouse
Composes a SVG graphic with the sketch of a house and alle sensor values and actuator states are visualized.
HV_showWeatherForecast
Just to indicate that the pulling of the weather forecast works, this fuctions reads the last line of the weather logfile and shows its values, plus an outlook of the next 48 h as graphic.
<?php /* published under GPL www.gnu.org/licenses/gpl.html */ session_start(); main(); function main(){ include("HV_setParameters.php"); include("HV_Admin_Login.php"); include("HV_serviceLog.php"); global $debug; $debug=FALSE; $parFile = "./ConfDir/parameters.yml"; $opModFile = "./ConfDir/operationMode.yml"; $head="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'> <html> <head> <title>Jachens Haustechnik</title>\n <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'> <meta name='keywords' content='Arne, Jachens'> <meta name='robots' content='noindex'> <meta name='robots' content='nofollow'> <meta name='autor' content='arne jachens'> <meta http-equiv='Cache-Control' content='no-store' /> <link rel='STYLESHEET' href='./HV_layout.css'> <!-- <link rel='STYLESHEET' href='.path.CMSlayout.css'>.extraStyle. --> <style type='text/css'> </style> <LINK REL='SHORTCUT ICON' HREF='./favicon.ico'> </head> <body> <a href='index.php'><h1>Jachens' Haustechnik</h1></a>\n"; if(isset($_SESSION['IamGod']) AND $_SESSION['IamGod']){ $form = "\n\n <p></p>"; $form.= HV_Admin_Login(); $foot = $form; }else{ $foot =""; } $foot.="</body></html>"; $what2do="showHouse"; #default if(isset($_GET['what2do'])){ $what2do=$_GET['what2do']; if(!isset($_SESSION['IamGod']) OR (isset($_SESSION['IamGod']) AND !$_SESSION['IamGod'])){ $what2do="login"; } } HV_readParameters($parFile); include_once("HV_readOperationState.php"); list($timeStamp,$sensors,$actuators,$operationMode) = HV_readOperationState($opModFile); if($debug){ echo "<p><aj>index(".$what2do.")</aj></p>\n"; } $content =""; switch($what2do){ case "restart": include("HV_restart.php"); $content.= HV_restart(); break; case "TempCal": include("HV_TempCal.php"); $content.= HV_TempCal1(); break; case "TempCal2": include("HV_TempCal.php"); $content.= HV_TempCal2(); /* fall throught */ case "login": $content.= HV_Admin_Login(); if(!isset($_SESSION['IamGod'])){break;} if(!$_SESSION['IamGod']){ break; }else{ /* fall through */ } case "showLog": include("HV_showLog.php"); $content.= HV_showLog($timeStamp); break; case "HeatCal": include("HV_TempCal.php"); $content.= HV_HeatCal1(); break; case "HeatCal2": include("HV_TempCal.php"); $content.= HV_HeatCal2(); /* fall throught */ case "menu": $content.= HV_showSwitches($operationMode); $content.= "\n<p style='text-align:center; max-width:600px;'><a href='?what2do=showLog'>show Logfile</a></p>\n"; break; case "editParams": $content.= HV_editParameters($parFile); $content.= HV_Admin_Login(); $content.= "<p align='center'><a href='?what2do=restart'>restart heating control</a></p>"; break; case "ventilation": break; case 'updateService': $fname="Configuration/HV_serviceLog.dat"; HV_serviceUpdateLog($fname); // fall through case 'showServiceLog': $fname="Configuration/HV_serviceLog.dat"; $content.=HV_serviceShowLog($fname); break; case "writeConfig": HV_writeConfig($opModFile); case "writeParameters": HV_writeParameters($parFile); $parameters = HV_readParameters($parFile); #$debug = $parameters['debug']; /* fall through */ default: include_once("readFilenames.php"); include("HV_showHouse.php"); include("HV_showWeatherForecast.php"); $today=date('Y-m-d'); $hour = date('H'); $minutes = date('i'); $weather = HV_actualWeather($today,$hour,$minutes); $content.= HV_showHouse($sensors,$actuators,$operationMode); $content.= "\n<p align='center'><a href='?what2do=showLog'>show Logfile</a></p>\n"; $content.= "<p><em>".$timeStamp."</em></p>"; $content.= "<p><em>".$today." ".$hour.":".$minutes."</em></p>"; $content.= HV_showWeatherForecast($weather); } /* show actual page */ echo $head; echo $content; echo $foot; } ?>
Index of Library
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.