Hamburger Hamburger

Heating and Ventilation Control

/index

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:

  1. Pagelayout
    With the strings $head and $foot the layout for all pages is centrally defined.
  2. 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'>
<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 "gate":
      include_once("HV_moveGate.php");
      $foot ="</body></html>";
      echo $head;
      echo HV_gateButton(2);
      echo $foot;
      exit();
      break;
  case "gateMove":
      include_once("HV_moveGate.php");
      $content.= HV_gateMove();
      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 class='formField' style='text-align:center; max-width:600px;'><a href='?what2do=showLog'>show Logfile</a></p>\n";
    break;
  case "editParams":
    $content.= HV_editParameters($parFile);
    $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');
    /* intepolate weather forecast to current minute */
    $weather = HV_actualWeather($today,$hour,$minutes);
    $content.= HV_showHouse($sensors,$actuators,$operationMode);
    $content.= "\n<p class='formField' align='center'><a href='?what2do=showLog'>show Logfile</a></p>\n";
    /* display timestamp to check server is alive */
    $content.= "<p><em>".$timeStamp."</em></p>";
    $content.= "<p><em>".$today." ".$hour.":".$minutes."</em></p>";
    /* merge weather of next days, create and run gnuplot -> longrunner? */
    $content.= HV_showWeatherForecast($weather);
  }
  /* show actual page */
  echo $head;
  echo $content;
  echo $foot;
}

?>

python

1/HvcLightControl.py
2/HvcHCSR04ultrasonic.py
3/HvcPV.py
4/HvcMotorDriver.py
5/HvcRollerShutter.py
6/manGenMqttMap.py
7/HvcReadSPI.py
8/HvcMqtt.py
9/HvcTables.py
10/HvcMain.py
11/HvcSetGPIO.py
12/HvcWifiRelay.py
13/HvcOperationMode.py
14/HvcControl.py
15/HvcRaw2phys.py
16/HvcWeather.py
17/HvcOneWire.py
18/makeDoc.py
19/HvcFronius.py
20/EnergyManager.py
21/HvcSendI2C.py

php

1/HV_colorMap.php
2/HV_Admin_Login.php
3/HV_readOperationState.php
4/HV_setParameters.php
5/HV_config.php
6/EM_handleJSON.php
7/index.php
8/readFilenames.php
9/HV_restart.php
10/HV_moveGate.php
11/HV_showLog.php
12/HV_RollerShutter.php
13/EM_editParameter.php
14/HV_serviceLog.php
15/HV_H2Olevel.php
16/HV_TempCal.php
17/HV_Fronius.php
18/EM_plot.php
19/readNamedData.php
20/HV_composeH2Oplot.php
21/HVdoc.php
22/HV_showWeatherForecast.php
23/HV_showHouse.php

Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.