Heating and Ventilation Control
/HV_moveGate
Keine Erläuterungen gefunden.
<?php function HV_gateButton($step){ $tm = time(); if($step==2){ $form = "<form action='?what2do=gateMove' method='POST'>\n"; $form.= "<input type='hidden' name='tm' value='".$tm."'>\n"; $form.= "<INPUT class='buttonGate' style='color:white; background-color:green' name='Garagentor' TYPE=submit VALUE='GaragenTor\nBist du dir sicher?'>\n"; $form.= "</form>\n"; $html = "<h1>Du willst das Garagentor bedienen?</h1>\n"; $html.= "<div style='text-align:center;'>".$form."</div>\n"; }else{ $form.= "<form action='?what2do=gate' method='POST'>\n"; $form.= "<input type='hidden' name='tm' value='".$tm."'>\n"; $form.= "<INPUT class='buttonGate' style='color:white; background-color:green' name='Garagentor' TYPE=submit VALUE='Garagen-\nTor'>\n"; $form.= "</form>\n"; $html = $form; } return $html; } function HV_gateMove(){ /* sudo apt update sudo apt-get install php7.4-curl. php --ri curl | grep "cURL support => enabled" */ $relayUri = "http://192.168.178.201"; $relayOn = $relayUri."/relay/0?turn=on"; $relayOff = $relayUri."/relay/0?turn=off"; $time = time(); $delta = 1*($time - $_POST['tm']); if($delta>10 OR $delta<0.2){ $html = "<p><b>mit deinem Timing stimmt was nicht!</b><br/>Versuch's nochmal</p>"; }else{ $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $relayOn, CURLOPT_SSH_COMPRESSION => true, ]); $result1 = curl_exec($ch); #wait 2 sec and switch off again time_sleep_until($time+2); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $relayOff, CURLOPT_SSH_COMPRESSION => true, ]); $result2 = curl_exec($ch); $html = "<h1 style='color:red; background-color:yellow;padding-left:4em;'>Tor fährt....</h1>\n"; $html.= "<div style='height:600px;'> </div>\n"; $log = fopen("Gate.log","a"); $dt = date('Y-m-d H:i:s', $time); fputs( $log, $dt."\t".$result1."\t".$result2."\n" ); fclose($log); } #fi return $html; } ?>
python
php
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.