Beide Wallboxen werden gleich bedient
carEG.php und carOG.php waren fast identisch und unterschieden sich nur im Transportweg: der go-e bekam seine Kommandos per HTTP, die Wattpilot ueber einen eigenen Python-Prozess je Klick, der sich einen Websocket aufbaute, anmeldete, ein Feld setzte und wieder starb. Beide haengen laengst am selben MQTT-Broker - der go-e mit eigenem Client (mce=true, mcr=false), die Wattpilot ueber wattpilot_bruecke.py. Beide nehmen Kommandos auf <praefix><schluessel>/set entgegen. Die Steuerung steht deshalb jetzt einmal in carSteuerung.php; was die Wallboxen wirklich trennt - Topic-Praefix, die Namen ate/att gegen ftt/fte und die Wattstunden je Prozent - steht als Tabelle in restricted/wallboxen.php. Nebenbei faellt damit /volume1/homes/wagner/wattpilot.py weg, das das Passwort der Wallbox im Klartext enthaelt und ausserhalb jedes Repos liegt. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+12
-73
@@ -1,73 +1,12 @@
|
||||
<?php
|
||||
|
||||
require_once("../helper.php");
|
||||
|
||||
if (checkLogin()) {
|
||||
chdir("/volume1/homes/wagner/");
|
||||
putenv('PYTHONPATH="/var/services/homes/wagner/.local/lib/python3.8/site-packages/');
|
||||
$close = 0;
|
||||
if (isset($_POST["evStart/Stop"])) {
|
||||
if ($_POST["evStart/Stop"] == "Laden starten") {
|
||||
$close = 1;
|
||||
exec("python wattpilot.py -start 2>&1", $output, $return_var);
|
||||
} elseif ($_POST["evStart/Stop"] == "Laden stoppen") {
|
||||
$close = 1;
|
||||
exec("python wattpilot.py -stop 2>&1", $output, $return_var);
|
||||
}
|
||||
$close = 1;
|
||||
} else if (isset($_POST["evMode"])) {
|
||||
// Eingaben pruefen, bevor sie in die Kommandozeile gehen. ftt kam bisher
|
||||
// ungeprueft aus dem Formular und liess sich mit "12:00; befehl" zum
|
||||
// Anhaengen beliebiger Shell-Befehle missbrauchen.
|
||||
$fte = intval($_POST["fte"]);
|
||||
if ($fte > 100)
|
||||
$fte = 100;
|
||||
else if ($fte < 1)
|
||||
$fte = 1;
|
||||
$fte = $fte * 140;
|
||||
|
||||
$evAmp = intval($_POST["evAmp"]);
|
||||
if ($evAmp > 16)
|
||||
$evAmp = 16;
|
||||
if ($evAmp < 6)
|
||||
$evAmp = 6;
|
||||
|
||||
// Das Formularfeld ist ein <input type="time">, liefert also HH:MM.
|
||||
// Alles andere gilt als "keine Ladeplanung" und faellt in den else-Zweig.
|
||||
$ftt = "";
|
||||
if (isset($_POST["ftt"]) && preg_match('/^([01][0-9]|2[0-3]):[0-5][0-9]$/', $_POST["ftt"])) {
|
||||
$ftt = $_POST["ftt"];
|
||||
}
|
||||
$setTime = gmdate("Y-m-d\TH:i:s", time()) . ".000";
|
||||
|
||||
if ($_POST["evMode"] == "eco") {
|
||||
$close = 1;
|
||||
if ($ftt !== "" && $fte > 0) {
|
||||
exec("python wattpilot.py -eco -time " . escapeshellarg($ftt) . " -energy " . $fte . " -maxCurr " . $evAmp . " -setTime " . escapeshellarg($setTime) . " 2>&1", $output, $return_var);
|
||||
} else {
|
||||
exec("/bin/python wattpilot.py -e 2>&1", $output, $return_var);
|
||||
}
|
||||
} else if ($_POST["evMode"] == "default") {
|
||||
$close = 1;
|
||||
if ($ftt !== "" && $fte > 0) {
|
||||
exec("python wattpilot.py -default -time " . escapeshellarg($ftt) . " -energy " . $fte . " -maxCurr " . $evAmp . " -setTime " . escapeshellarg($setTime) . " 2>&1", $output, $return_var);
|
||||
} else {
|
||||
exec("python wattpilot.py -d 2>&1", $output, $return_var);
|
||||
}
|
||||
} else if ($_POST["evMode"] == "NextTrip") {
|
||||
$close = 1;
|
||||
if ($ftt !== "" && $fte > 0) {
|
||||
exec("python wattpilot.py -trip -time " . escapeshellarg($ftt) . " -energy " . $fte . " -maxCurr " . $evAmp . " -setTime " . escapeshellarg($setTime) . " 2>&1", $output, $return_var);
|
||||
} else {
|
||||
exec("python wattpilot.py -t 2>&1", $output, $return_var);
|
||||
}
|
||||
}
|
||||
$close = 1;
|
||||
}
|
||||
} else {
|
||||
$close = 1;
|
||||
}
|
||||
if (!$close) {
|
||||
$formId = "carEG_form";
|
||||
include __DIR__ . "/carForm.php";
|
||||
}
|
||||
<?php
|
||||
/*
|
||||
* Autoladung EG - die Wattpilot in der Garage.
|
||||
*
|
||||
* Die Ansteuerung ist fuer beide Wallboxen dieselbe und steht in
|
||||
* carSteuerung.php; hier bleibt nur, welche gemeint ist.
|
||||
*/
|
||||
|
||||
$wallbox = "eg";
|
||||
$formId = "carEG_form";
|
||||
|
||||
require __DIR__ . "/carSteuerung.php";
|
||||
|
||||
Reference in New Issue
Block a user