Easee Solarladen hinzugefühgt

This commit is contained in:
dh
2025-05-01 16:12:30 +02:00
parent 6baf22f722
commit d46188e20c
2 changed files with 95 additions and 11 deletions
+18 -6
View File
@@ -22,7 +22,7 @@
"value": 4 "value": 4
}, },
{ {
"caption": "Easee", "caption": "Easee - Nur Solarladen",
"value": 5 "value": 5
} }
] ]
@@ -48,7 +48,7 @@
{ {
"type": "NumberSpinner", "type": "NumberSpinner",
"name": "Zeit_Zwischen_Zustandswechseln", "name": "Zeit_Zwischen_Zustandswechseln",
"caption": "Mindestlaufzeit des Verbrauchers bei Lastschaltung", "caption": "Mindestlaufzeit des Verbrauchers bei Lastschaltung (Für Easee Solarladen zwingend 1 Minute einstellen)",
"suffix": "" "suffix": ""
}, },
{ {
@@ -58,25 +58,37 @@
}, },
{ {
"type": "ValidationTextBox", "type": "ValidationTextBox",
"name": "ID", "name": "Geräte-ID Smart-Me / ECarUp / Easee",
"caption": "ID" "caption": "ID"
}, },
{ {
"type": "ValidationTextBox", "type": "ValidationTextBox",
"name": "Seriennummer", "name": "Seriennummer Smart-Me / ECarUp / Easee",
"caption": "Seriennummer" "caption": "Seriennummer"
}, },
{ {
"type": "ValidationTextBox", "type": "ValidationTextBox",
"name": "Username", "name": "Username / Benutzernahme Solarladen",
"caption": "Username" "caption": "Username"
}, },
{ "type": "PasswordTextBox", { "type": "PasswordTextBox",
"name": "Password", "name": "Password -> Bei Anwendung mit Pico-Stationen",
"caption": "Passwort" "caption": "Passwort"
},
{
"type": "SelectVariable",
"name": "Token_Easee",
"caption": "Variable API-Token für Easee",
"suffix": ""
},
{
"type": "SelectVariable",
"name": "Token_ECarUp",
"caption": "Variable API-Token für ECarUp",
"suffix": ""
} }
] ]
+76 -4
View File
@@ -17,6 +17,8 @@ class Ladestation_v2 extends IPSModule
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval $this->RegisterPropertyInteger("Interval", 5); // Recheninterval
$this->RegisterPropertyInteger("Max_Current_abs", 32); // Recheninterval $this->RegisterPropertyInteger("Max_Current_abs", 32); // Recheninterval
$this->RegisterPropertyInteger("Zeit_Zwischen_Zustandswechseln", 1); $this->RegisterPropertyInteger("Zeit_Zwischen_Zustandswechseln", 1);
$this->RegisterPropertyInteger("Token_Easee", 0); // Recheninterval
$this->RegisterPropertyInteger("Token_ECarUp", 0); // Recheninterval
// Ladestationspezifische Variabeln // Ladestationspezifische Variabeln
@@ -322,16 +324,53 @@ class Ladestation_v2 extends IPSModule
break; break;
case 4: case 4:
$this->SetValue("Car_detected", true); $car_on_station = true;
break; break;
case 5: case 5:
echo "Fall 5";
// Benutzer eCarUp abfragen
$authToken = GetValue($this->ReadPropertyInteger("Token_ECarUp"));
$ID = $this->ReadPropertyInteger("ID");
$apiUrl = 'https://public-api.ecarup.com/v1/station/' . $ID . '/conn'.'ectors/'. $ID . '/active-charging';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'accept: application/json',
'Authorization: Bearer ' . $authToken
]);
$response = curl_exec($ch);
curl_close($ch);
if ($response === false) {
IPS_LogMessage("Ladestation", "Fehler beim Abrufen der eCarUp API-Daten");
return;
}
$data = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
IPS_LogMessage("Ladestation", "Fehler beim Dekodieren der JSON-Antwort");
return;
}
if (isset($data['driverIdentifier']) && ($data['driverIdentifier']==$this->ReadPropertyInteger("Username"))) {
$this->SetValue("Ladeleistung_Effektiv", $this->GetValue("Power"));
$this->SetValue("Fahrzeugstatus", 2);
$car_on_station = true;
} else {
$car_on_station = false;
$this->SetValue("Fahrzeugstatus", 1);
$this->SetValue("Ladeleistung_Effektiv", 0);
}
break; break;
default: default:
$this->SetValue("Car_detected", false); $this->SetValue("Car_detected", false);
$this->SetValue("Fahrzeugstatus", -1); $this->SetValue("Fahrzeugstatus", -1);
break; break;
} }
@@ -527,6 +566,9 @@ class Ladestation_v2 extends IPSModule
case 4: case 4:
// Nichts zu tun für Dummy station // Nichts zu tun für Dummy station
return; return;
case 5:
// Keine base Url nötig
break;
} }
$ch = curl_init(); $ch = curl_init();
@@ -550,6 +592,21 @@ class Ladestation_v2 extends IPSModule
case 4: case 4:
// Nichts zu tun für Dummy station // Nichts zu tun für Dummy station
return; return;
case 5:
$url = "https://api.easee.com/api/chargers/".$this->GetValue("Seriennummer")."/commands/set_dynamic_charger_current"
curl_setopt_array($ch, [
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"amps\":". $value .",\"minutes\":1}",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer ".GetValue($this->ReadPropertyInteger("Token_Easee"))."",
"content-type: application/*+json"
],
]);
default: default:
return "Invalid station type."; return "Invalid station type.";
} }
@@ -577,6 +634,21 @@ class Ladestation_v2 extends IPSModule
case 4: case 4:
// Nichts zu tun für Dummy station // Nichts zu tun für Dummy station
return; return;
case 5:
$url2 = "https://api.easee.com/api/chargers/".$this->GetValue("Seriennummer")."/commands/set_dynamic_charger_current"
curl_setopt_array($ch, [
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"amps\":". $value .",\"minutes\":1}",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer ".GetValue($this->ReadPropertyInteger("Token_Easee"))."",
"content-type: application/*+json"
],
]);
break;
default: default:
return "Invalid station type."; return "Invalid station type.";
} }