Hamburger Hamburger

Heating and Ventilation Control

/HV_setParameters

Keine Erläuterungen gefunden.

<?php 
/* published under GPL www.gnu.org/licenses/gpl.html */
function HV_showSwitches($opMod){
  include("HV_config.php");
  $menu = "<form action='?what2do=writeConfig' method='POST'>\n";
  $menu.= "<table border='0' style='min-width:640px;'>\n";
  $menu.= "<tr><td class='light formField'>Heizmodus:</td><td class='light formField'> </td>
           <td align='right' class='light formField'>Winter:   <input class='formField' type='radio' name='opMod' value='winter'";
  if($opMod['opMod']=="winter"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='light formField'>Sommer:   <input class='formField' type='radio' name='opMod' value='summer'";
  if($opMod['opMod']=="summer"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td class='light formField'> </td><td align='right' class='light formField'>Urlaub <input class='formField' type='radio' name='opMod' value='vacation'";
  if($opMod['opMod']=="vacation"){$menu.= "checked='checked'";}
  $menu.= "></td></tr>\n";

  $menu.= "<tr><td class='dark formField'>Solar:</td>
           <td align='right' class='dark formField'>ON   <input class='formField' type='radio' name='stateSolar' value='on'";
  if($opMod['solar']=="on"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='dark formField'>OFF  <input class='formField' type='radio' name='stateSolar' value='off'";
  if($opMod['solar']=="off"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='dark formField'>AUTO <input class='formField' type='radio' name='stateSolar' value='auto'";
  if($opMod['solar']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td><td class='dark formField'> </td><td class='dark formField'> </td></tr>\n";

  $menu.= "<tr><td class='light formField'>Ofen:</td>
           <td align='right' class='light formField'>ON   <input class='formField' type='radio' name='stateOven' value='on'";
  if($opMod['oven']=="on"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='light formField'>OFF  <input class='formField' type='radio' name='stateOven' value='off'";
  if($opMod['oven']=="off"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='light formField'>AUTO <input class='formField' type='radio' name='stateOven' value='auto'";
  if($opMod['oven']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td><td class='light formField'> </td><td class='light formField'> </td></tr>\n";

  $menu.= "<tr><td class='dark formField'>Pumpe:</td>
           <td align='right' class='dark formField'>ON   <input class='formField' type='radio' name='statePump' value='on'";
  if($opMod['pump']=="on"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='dark formField'>OFF  <input class='formField' type='radio' name='statePump' value='off'";
  if($opMod['pump']=="off"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='dark formField'>AUTO <input class='formField' type='radio' name='statePump' value='auto'";
  if($opMod['pump']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td><td class='dark formField'> </td><td class='dark formField'> </td></tr>\n";

/*
  $menu.= "<tr><td>Printer:</td>
           <td align='right'>ON   <input class='formField' type='radio' name='stateServ' value='on'";
  if($opMod['']=="on"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>OFF  <input class='formField' type='radio' name='stateServ' value='off'";
  if($opMod['']=="off"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right'>AUTO <input class='formField' type='radio' name='stateServ' value='auto'";
  if($opMod['']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td><td> </td><td> </td></tr>\n";
*/

  $menu.= "<tr><td class='light formField'>Bypass:</td>
           <td align='right' class='light formField'>OPEN   <input class='formField' type='radio' name='stateBP' value='open'";
  if($opMod['byPs']=="open"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='light formField'>SHUT  <input class='formField' type='radio' name='stateBP' value='shut'";
  if($opMod['byPs']=="shut"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='light formField'>AUTO <input class='formField' type='radio' name='stateBP' value='auto'";
  if($opMod['byPs']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td><td class='light formField'> </td><td class='light formField'> </td></tr>\n";

  $menu.= "<tr><td class='dark formField'>Lüftung:</td>
           <td align='right' class='dark formField'>OFF   <input class='formField' type='radio' name='stateVent' value='off'";
  if($opMod['vent']=="off"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='dark formField'>min  <input class='formField' type='radio' name='stateVent' value='minimal'";
  if($opMod['vent']=="minimal"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='dark formField'>normal <input class='formField' type='radio' name='stateVent' value='normal'";
  if($opMod['vent']=="normal"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='dark formField'>  max <input class='formField' type='radio' name='stateVent' value='maximal'";
  if($opMod['vent']=="maximal"){$menu.= "checked='checked'";}
  $menu.= "></td>
           <td align='right' class='dark formField'>AUTO <input class='formField' type='radio' name='stateVent' value='auto'";
  if($opMod['vent']=="auto"){$menu.= "checked='checked'";}
  $menu.= "></td></tr>\n";

  $menu.= "<tr><td colspan='6' align='center'> </td></tr>\n";
  $menu.= "<tr><td colspan='6' align='center'><input class='formField' type='submit' value='submit' style='font-size:x-large;'></td></tr>\n";
  $menu.= "</table>\n</form>\n";
  
  return $menu;
}

function HV_writeConfig($confFile){
    $failCount=0;
    if(isset($_POST['stateSolar'])) {$opMod['solar'] = $_POST['stateSolar'];}else{$failcount++;}
    if(isset($_POST['stateOven']))  {$opMod['oven']  = $_POST['stateOven'];}else{$failcount++;}
    if(isset($_POST['statePump']))  {$opMod['pump']  = $_POST['statePump'];}else{$failcount++;}
    if(isset($_POST['stateVent']))  {$opMod['vent']  = $_POST['stateVent'];}else{$failcount++;}
    if(isset($_POST['stateBP']))    {$opMod['byPs']  = $_POST['stateBP'];}else{$failcount++;}
    if(isset($_POST['opMod']))      {$opMod['opMod'] = $_POST['opMod'];}else{$failcount++;}

    $keys = array_keys($opMod);
    $opModStr = "{";
    $opModStr .= "\"".$keys[0]."\": \"".$opMod[$keys[0]]."\"";
    for($o=1;$o<count($opMod);$o++){
        $opModStr .= ", \"".$keys[$o]."\": \"".$opMod[$keys[$o]]."\"";
    } #o
    $opModStr .= "}";

    if ($failCount==0){  
        $pf = fopen($confFile,"w");
        fputs($pf,$opModStr);
        fclose($pf);
    }else{
        echo "<p><b>Writing operation Mode failed!</b></p>";
    }
 }

function HV_editParameters($parFile){
    $parDesc["THausSoll"] = "Zieltemperatur unseres Hauses, wenn es in Marens Zimmer kälter ist, Schaltet die Heizung ein. (21.3 C)";
    $parDesc["TOfenAn"] = "Speichertemperatur, bei der der Ofen eingeschaltet wird";
    $parDesc["TOfenAus"] = "Speichertemperatur, bei der der Ofen ausgeschaltet wird";
    $parDesc["DeltaTKollektor"] = "Soviel muss der Kollektor wärmer sein als der Speicher, damit die Solaranlage eingeschaltet wird";
    $parDesc["hourSolarOff"] = "ab dieser Stunde wird (im Winter) die Solaranlage nicht mehr eingeschaltet";
    $parDesc["ventMinimal"] = "Level Lüftungsansteuerung [0:1]";
    $parDesc["ventNormal"] = "Level Lüftungsansteuerung [0:1]";
    $parDesc["debug"] = "Setze <tt>debug=True</tt>, um zu sehen, wie die Skripte durchlaufen werden.";
    
    $parameters = HV_readParameters($parFile);
    
    $menu = "<form action='?what2do=writeParameters' method='POST'>\n";
    $menu.= "<table border='0'>\n";
    $keys = array_keys($parameters);
    for($k=0;$k<count($keys);$k++){
        $thisPar = $keys[$k];
        $menu.= "<tr><td>".$thisPar.":</td>";
        $menu.= "<td><input class='formField' type='text' name='".$thisPar."' value='".$parameters[$thisPar]."' length='4'></td>";
        $menu.= "<td>".$parDesc[$thisPar]."</td></tr>";
        
    } #k

    $menu.= "<tr><td colspan='2' align='center'><input class='formField' type='submit' name='' value='submit'></td>
<td><!--<a href='?what2do=TempCal'>Temperatur Kalibrierung</a>-->
<a href='?what2do=HeatCal'>Steuerkurven</a></td></tr>\n";
    $menu.= "</table>\n";
    $menu.= "</form>\n";

  return $menu;


}

function HV_writeParameters($paramFile){
    global $debug;
    if($debug){
        echo "<p><aj>HV_writeParameters( )</aj>: ".$paramFile."</p>\n";
    }
    
    /* check for  available parameters */
    $parameters = HV_readParameters($paramFile);
    $keys = array_keys($parameters);
    
    /* POST values from form */
    $failcount=0;
    for($k=0;$k<count($keys);$k++){
        $thisPar = $keys[$k];
        if(isset($_POST[$thisPar])) {
            $parameters[$thisPar] = $_POST[$thisPar];
        }else{
            $failcount++;
            if($debug){echo "POST[".$thisPar."] did not work</br>";}
        }
    } #k
    if($parameters['debug']!=TRUE and $parameters['debug']!="True"){
        $debug = FALSE;
    }
        
    /* compose yml */
    $paramStr = "{";
    $paramStr .= "\"".$keys[0]."\": \"".$parameters[$keys[0]]."\"";
    for($o=1;$o<count($keys);$o++){
        $paramStr .= ", \"".$keys[$o]."\": \"".$parameters[$keys[$o]]."\"";
    } #o
    $paramStr .= "}";

    if ($failcount==0){  
        $pf = fopen($paramFile,"w");
        fputs($pf,$paramStr);
        fclose($pf);
    }else{
        if(!isset($_POST['opMod'])){
            echo "<p><b>Writing parameters failed!</b></p>";
        } #skip waring, when fallthrough from opMod
    }
    

    return "<p>parameters written</p>";
}

function HV_readParameters($parFile){
    global $debug;
    $fid = fopen($parFile,"r");
    $paramStr = trim(fgets($fid,2048));  
    fclose($fid);
    $paramStr = substr($paramStr,1);
    $paramStr = substr($paramStr,0,strlen($paramStr)-2);
    $paramStr = str_replace("\"","",$paramStr);
    $tmp = explode(",",$paramStr);
    for($m=0;$m<count($tmp);$m++){
        $thisM = explode(":",$tmp[$m]);
        $parameters[trim($thisM[0])] = trim($thisM[1]);
    } #m

    if($parameters['debug']!=TRUE and $parameters['debug']!="True"){
        $debug = FALSE;
    }
    if($debug){
        echo "<p><aj>HV_readParameters( )</aj></p>\n";
        print_r($parameters);
    }
    return $parameters;
}




?>

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.