Ladestation für Solarladen Easee angepasst

This commit is contained in:
2025-06-24 11:09:28 +02:00
parent 855334f2ef
commit b10764423b
2 changed files with 34 additions and 29 deletions

View File

@@ -43,6 +43,8 @@ class Ladestation_v2 extends IPSModule
$this->RegisterVariableBoolean("IsTimerActive", "IsTimerActive", "", false);
$this->RegisterTimer("ZustandswechselTimer",0,"IPS_RequestAction(" .$this->InstanceID .', "ResetTimer", "");');
$this->RegisterVariableString("Letzer_User", "Letzter registrierter Benutzer", "", "");
// Variabeln für Kommunkation mit Manager
@@ -345,7 +347,22 @@ class Ladestation_v2 extends IPSModule
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
if (json_last_error() === JSON_ERROR_NONE && isset($data["driverIdentifier"])) {
$this->SetValue("Letzer_User", $data["driverIdentifier"]);
if($this->ReadPropertyString("Username") === $data["driverIdentifier"]){
$this->SetValue("Solarladen", true);
}else{
$this->SetValue("Solarladen", false);
}
}
//Aktueller Zustand Ladestation abfragen (Leistung, auto eingesteckt?)
$ch2 = curl_init();
$url2 = "https://api.easee.com/api/chargers/".$this->ReadPropertyString("Seriennummer")."/state";
@@ -366,39 +383,21 @@ class Ladestation_v2 extends IPSModule
$response_easee = curl_exec($ch2);
curl_close($ch2);
IPS_LogMessage("Easee", print_r($response_easee));
if ($response === false) {
IPS_LogMessage("Ladestation", "Fehler beim Abrufen der API-Daten");
return;
}
$easee_data = json_decode($response_easee, true);
$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->ReadPropertyString("Username"))) {
if(isset($easee_data["totalPower"])){
$this->SetValue("Ladeleistung_Effektiv", round($easee_data["totalPower"]*1000));
IPS_LogMessage("Ladestation 1", "1");
}else{
$this->SetValue("Ladeleistung_Effektiv", 0);
IPS_LogMessage("Ladestation 0", "0");
if (json_last_error() === JSON_ERROR_NONE && isset($easee_data["chargerOpMode"])) {
if ($easee_data["chargerOpMode"] != 1) {
$car_on_station = true;
}
$this->SetValue("Fahrzeugstatus", 2);
$car_on_station = true;
} else {
$car_on_station = false;
$this->SetValue("Fahrzeugstatus", 1);
$this->SetValue("Ladeleistung_Effektiv", 0);
else{
$car_on_station = false;
}
$this->SetValue("Ladeleistung_Effektiv", round($easee_data["totalPower"]*1000));
$this->SetValue("Fahrzeugstatus", $easee_data["chargerOpMode"]);
}
break;
default:
@@ -626,6 +625,9 @@ class Ladestation_v2 extends IPSModule
// Nichts zu tun für Dummy station
return;
case 5:
if($this->ReadPropertyString("Username") != $data["driverIdentifier"]){
return;
}
$url = "https://api.easee.com/api/chargers/".$this->ReadPropertyString("Seriennummer")."/commands/set_dynamic_charger_current";
curl_setopt_array($ch, [
CURLOPT_ENCODING => "",
@@ -668,6 +670,9 @@ class Ladestation_v2 extends IPSModule
// Nichts zu tun für Dummy station
return;
case 5:
if($this->ReadPropertyString("Username") != $data["driverIdentifier"]){
return;
}
$url2 = "https://api.easee.com/api/chargers/".$this->ReadPropertyString("Seriennummer")."/commands/set_dynamic_charger_current";
curl_setopt_array($ch, [
CURLOPT_ENCODING => "",

View File

@@ -19,7 +19,7 @@ class PV_Visu extends IPSModule
public function ApplyChanges()
{
parent::ApplyChanges();
$this->UpdateData();
$this->RequestAction("update", 1);
}
/**