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
php
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.