no message
This commit is contained in:
@@ -260,173 +260,6 @@ class Ladestation_v2 extends IPSModule
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function Detect_Car(int $carType)
|
||||
{
|
||||
|
||||
if($this->GetValue("Car_Detected")){
|
||||
if($this->Get_Car_Status($carType)==true){
|
||||
$this->SetValue("Car_Detected", true);
|
||||
}else{
|
||||
$this->SetValue("Car_Detected", false);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if($this->Get_Car_Status($carType)==true){
|
||||
|
||||
$this->sendPowerToStation(32);
|
||||
|
||||
$counter = $this->GetValue("Pending_Counter");
|
||||
|
||||
if($counter>(20/($this->ReadPropertyInteger("Interval")*1000))){
|
||||
|
||||
$this->SetValue("Pending_Counter", 0);
|
||||
if($this->GetValue("Ladeleistung_Effektiv")>7500){
|
||||
$this->SetValue("Is_1_ph", false);
|
||||
|
||||
}
|
||||
else{
|
||||
$this->SetValue("Is_1_ph", true);
|
||||
}
|
||||
|
||||
$this->Calc_Max_Current($this->GetValue("Is_1_ph"));
|
||||
$this->SetValue("Car_Detected", true);
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
$this->SetValue("Pending_Counter", $counter+1);
|
||||
$this->SetValue("Car_Detected", false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
$this->SetValue("Car_Detected", false);
|
||||
}
|
||||
}
|
||||
return $this->GetValue("Car_Detected");
|
||||
|
||||
}
|
||||
|
||||
public function Get_Car_Status(int $carType)
|
||||
{
|
||||
$plug_state = false;
|
||||
$ch = curl_init();
|
||||
|
||||
switch ($carType) {
|
||||
case 1:
|
||||
curl_setopt($ch, CURLOPT_URL, "http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload=");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($data["car"])) {
|
||||
if ($data["car"] != 1) {
|
||||
$plug_state = true;
|
||||
}
|
||||
$this->SetValue("Ladeleistung_Effektiv", $data["nrg"][11]*10);
|
||||
$this->SetValue("Fahrzeugstatus", $data["car"]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
curl_setopt($ch, CURLOPT_URL, "http://" . $this->ReadPropertyString("IP_Adresse") . "/api/status");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($data["car"])) {
|
||||
if ($data["car"] != 1) {
|
||||
$plug_state = true;
|
||||
}
|
||||
$this->SetValue("Ladeleistung_Effektiv", $data["nrg"][11]);
|
||||
$this->SetValue("Fahrzeugstatus", $data["car"]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
curl_setopt($ch, CURLOPT_URL, "https://api.smart-me.com/pico/charging/" . $this->ReadPropertyString("ID"));
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $this->ReadPropertyString("Username") . ":" . $this->ReadPropertyString("Password"));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($data["State"])) {
|
||||
if ($data["State"] != 1) {
|
||||
$plug_state = true;
|
||||
}
|
||||
$this->SetValue("Ladeleistung_Effektiv", round($data["ActiveChargingPower"]*1000));
|
||||
$this->SetValue("Fahrzeugstatus", $data["State"]);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$plug_state = true;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
echo "Fall 5";
|
||||
break;
|
||||
|
||||
default:
|
||||
$plug_state = false;
|
||||
$this->SetValue("Fahrzeugstatus", -1);
|
||||
break;
|
||||
}
|
||||
|
||||
$this->SetValue("Car_detected", $plug_state);
|
||||
|
||||
return $plug_state;
|
||||
}
|
||||
|
||||
public function Calc_Max_Current(bool $is_1_ph)
|
||||
{
|
||||
$maxCurrent = 32;
|
||||
if($is_1_ph){
|
||||
$maxCurrent = 1.1 * ($this->GetValue("Ladeleistung_Effektiv") / 230);
|
||||
}
|
||||
else{
|
||||
$maxCurrent = 1.1 * ($this->GetValue("Ladeleistung_Effektiv") / (1.71*400));
|
||||
}
|
||||
if($maxCurrent>32){
|
||||
$maxCurrent = 32;
|
||||
}
|
||||
$this->SetValue("Max_Current", $maxCurrent);
|
||||
}
|
||||
|
||||
public function Get_Current_From_Power(bool $is_1_ph, int $power)
|
||||
{
|
||||
if ($is_1_ph) {
|
||||
$current = round($power / 230);
|
||||
} else {
|
||||
$current = round($power / (400 * 1.71));
|
||||
}
|
||||
|
||||
return $current;
|
||||
}
|
||||
|
||||
public function Get_Array_From_Current(bool $is_1_ph, float $current)
|
||||
{
|
||||
$resultArray = [];
|
||||
|
||||
for ($i = 6; $i <= $current; $i++) {
|
||||
if ($is_1_ph) {
|
||||
$resultArray[] = $i * 230;
|
||||
} else {
|
||||
$resultArray[] = $i * 400 * 1.71;
|
||||
}
|
||||
}
|
||||
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
|
||||
public function SetAktuelle_Leistung(int $power)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user