Hamburger Hamburger

Heating and Ventilation Control

/EM_handleJSON

Keine Erläuterungen gefunden.

<?php


function readJSON($file){
  $debug = TRUE;
  $debug = FALSE;
  $data = file_get_contents($file); 
  // JSON decode
  $dict = json_decode($data);
  if ($debug){
      echo $file."<br/>";
      print_r($dict);
      echo "<p>";
  }
  return $dict;
}

function writeJSON($dict,$file){
    $data = json_encode($dict);
    file_put_contents($file, $data);
}

function dict2param($dict){
  $debug = TRUE;
  $debug = FALSE;
  $parameter = get_object_vars($dict);
  if ($debug){
    echo "<p>parameters:"; print_r($parameter);
  }
  return $parameter;
}


function dict2table($dict,$roomSens){
  $debug = TRUE;
  $debug = FALSE;
  $vars = get_object_vars($dict);
  $sensNames = array_keys($vars);
  $firstSensCol = 5; #0:date, 1:time, 2:sunRise, 3:sunSet
  $fields = array_keys( get_object_vars($vars[$sensNames[$firstSensCol]]) );
  if ($debug){
    echo "<p>sensNames:"; print_r($sensNames);
    echo "<p>fields"; print_r($fields);
  }

  $table = "<table class='color' style='min-width:600px;'>\n";
  $table.= "<tr>\n  <th>Room</th><th class='dark'>Sensor</th>\n";
  for($f=0;$f<count($fields);$f++){
      $thisField = $fields[$f];
      if($thisField=="setpoint"){
          $thisField = "<a href='?what2do=editParameter'>".$thisField."</a>";
      }else if($thisField=="state"){
          $thisField = "".$thisField."";
      }else{
          $thisField = "<a href='?what2do=all&type=".$thisField."&date=".$vars['date']."'>".$thisField."</a>";
      }
      $table.= "  <th class='dark'>".$thisField."</th>\n";
  } #f
  $table.= "</tr>\n";
  for($s=0;$s<count($sensNames)-$firstSensCol;$s++){
    $ss = $s+$firstSensCol;
    $table.= "<tr>\n";
    $table.= "<td>".$roomSens[strtolower($sensNames[$ss])]."</td>";
    $table.= "<td style='text-align:center;'><a href='?what2do=plotRoom&room=";
    $table.= $sensNames[$ss]."&date=".$vars['date']."'>";
    $table.= $sensNames[$ss]."</a></td>\n";
    $theseVars = get_object_vars($vars[$sensNames[$ss]]);
    if ($debug){
      echo "<p>theseVars"; print_r($theseVars);
    }
    for($tv=0;$tv<count($theseVars);$tv++){
        if($fields[$tv]=="state"){
            if($theseVars[$fields[$tv]]>50){
                $indicator = "background-color #00ff00;";
            }else if($theseVars[$fields[$tv]]>20){
                $indicator = "background-color #ff9900;";
            }else{
                $indicator = "background-color #ff0000;";
            }
            $table.= "  <td style='text-align:center; ".$indicator."'>".$theseVars[$fields[$tv]]."</td>\n";
        }else{
            $table.= "  <td style='text-align:center;'>";
            $table.= sprintf('%5.2f',$theseVars[$fields[$tv]]);
                $table.= "</td>\n";
        }
    } #tv
    $table.= "</tr>\n";
  } #s



  $table.= "</table>\n\n";
  #$html = "\n<p>".$vars['date']."   ".$vars['time']."\n";
  #$html.= "   Sonnenuntergang:".$vars['sunSet']."</p>\n";
  $html.= $table;
$html.= "<p>Konfiguration des Zigbee Netzwerks:<br/><a href='http://192.168.178.111:65090/'>Zigbee2Mqtt</a></p>";
  return $html;
}

?>

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.