diff --git a/Ladestation_v2/module.php b/Ladestation_v2/module.php index 719e822..96ef12e 100644 --- a/Ladestation_v2/module.php +++ b/Ladestation_v2/module.php @@ -192,7 +192,6 @@ class Ladestation_v2 extends IPSModule public function Get_Car_Status(int $carType) { - $plug_state = false; $ch = curl_init(); switch ($carType) { @@ -205,7 +204,10 @@ class Ladestation_v2 extends IPSModule if (json_last_error() === JSON_ERROR_NONE && isset($data["car"])) { if ($data["car"] != 1) { - $plug_state = true; + $this->SetValue("Car_detected", true); + } + else{ + $this->SetValue("Car_detected", false); } $this->SetValue("Ladeleistung_Effektiv", $data["nrg"][11]*10); $this->SetValue("Fahrzeugstatus", $data["car"]); @@ -221,7 +223,10 @@ class Ladestation_v2 extends IPSModule if (json_last_error() === JSON_ERROR_NONE && isset($data["car"])) { if ($data["car"] != 1) { - $plug_state = true; + $this->SetValue("Car_detected", true); + } + else{ + $this->SetValue("Car_detected", false); } $this->SetValue("Ladeleistung_Effektiv", $data["nrg"][11]); $this->SetValue("Fahrzeugstatus", $data["car"]); @@ -239,7 +244,10 @@ class Ladestation_v2 extends IPSModule if (json_last_error() === JSON_ERROR_NONE && isset($data["State"])) { if ($data["State"] != 1) { - $plug_state = true; + $this->SetValue("Car_detected", true); + } + else{ + $this->SetValue("Car_detected", false); } $this->SetValue("Ladeleistung_Effektiv", round($data["ActiveChargingPower"]*1000)); $this->SetValue("Fahrzeugstatus", $data["State"]); @@ -248,7 +256,7 @@ class Ladestation_v2 extends IPSModule break; case 4: - $plug_state = true; + $this->SetValue("Car_detected", true); break; case 5: @@ -256,14 +264,13 @@ class Ladestation_v2 extends IPSModule break; default: - $plug_state = false; - $this->SetValue("Fahrzeugstatus", -1); + $this->SetValue("Car_detected", false); + $this->SetValue("Fahrzeugstatus", -1); break; } - $this->SetValue("Car_detected", $plug_state); - return $plug_state; + return $this->GetValue("Car_detected"); } public function Calc_Max_Current(bool $is_1_ph)