Easee Solarladen hinzugefühgt

This commit is contained in:
2025-05-01 16:12:30 +02:00
parent 6baf22f722
commit d46188e20c
2 changed files with 95 additions and 11 deletions

View File

@@ -22,7 +22,7 @@
"value": 4
},
{
"caption": "Easee",
"caption": "Easee - Nur Solarladen",
"value": 5
}
]
@@ -48,7 +48,7 @@
{
"type": "NumberSpinner",
"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": ""
},
{
@@ -58,26 +58,38 @@
},
{
"type": "ValidationTextBox",
"name": "ID",
"name": "Geräte-ID Smart-Me / ECarUp / Easee",
"caption": "ID"
},
{
"type": "ValidationTextBox",
"name": "Seriennummer",
"name": "Seriennummer Smart-Me / ECarUp / Easee",
"caption": "Seriennummer"
},
{
"type": "ValidationTextBox",
"name": "Username",
"name": "Username / Benutzernahme Solarladen",
"caption": "Username"
},
{ "type": "PasswordTextBox",
"name": "Password",
"name": "Password -> Bei Anwendung mit Pico-Stationen",
"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": ""
}
]
}

View File

@@ -17,6 +17,8 @@ class Ladestation_v2 extends IPSModule
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
$this->RegisterPropertyInteger("Max_Current_abs", 32); // Recheninterval
$this->RegisterPropertyInteger("Zeit_Zwischen_Zustandswechseln", 1);
$this->RegisterPropertyInteger("Token_Easee", 0); // Recheninterval
$this->RegisterPropertyInteger("Token_ECarUp", 0); // Recheninterval
// Ladestationspezifische Variabeln
@@ -322,16 +324,53 @@ class Ladestation_v2 extends IPSModule
break;
case 4:
$this->SetValue("Car_detected", true);
$car_on_station = true;
break;
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;
default:
$this->SetValue("Car_detected", false);
$this->SetValue("Fahrzeugstatus", -1);
$this->SetValue("Car_detected", false);
$this->SetValue("Fahrzeugstatus", -1);
break;
}
@@ -527,6 +566,9 @@ class Ladestation_v2 extends IPSModule
case 4:
// Nichts zu tun für Dummy station
return;
case 5:
// Keine base Url nötig
break;
}
$ch = curl_init();
@@ -550,6 +592,21 @@ class Ladestation_v2 extends IPSModule
case 4:
// Nichts zu tun für Dummy station
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:
return "Invalid station type.";
}
@@ -577,6 +634,21 @@ class Ladestation_v2 extends IPSModule
case 4:
// Nichts zu tun für Dummy station
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:
return "Invalid station type.";
}