Version 2.0.0 Beta
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
{
|
||||
"caption": "Smart-Me Pico",
|
||||
"value": 3
|
||||
},
|
||||
{
|
||||
"caption": "Dummy Station (Ohne Ansteuerung)",
|
||||
"value": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -42,9 +46,15 @@
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "IdleCounterMax",
|
||||
"caption": "Zyklen zwischen zwei Leistungsänderungen",
|
||||
"caption": "Zyklen zwischen zwei Leistungsänderungen (Multipliziert sich mit Interval)",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Interval",
|
||||
"caption": "Intervall Neuberechnung der Werte",
|
||||
"suffix": "Sekunden"
|
||||
},
|
||||
{
|
||||
"type": "ValidationTextBox",
|
||||
"name": "IP_Adresse",
|
||||
|
||||
@@ -17,6 +17,7 @@ class Ladestation_Universal extends IPSModule
|
||||
$this->RegisterPropertyString("Seriennummer", "");
|
||||
$this->RegisterPropertyString("Username", "");
|
||||
$this->RegisterPropertyString("Password", "");
|
||||
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
|
||||
|
||||
|
||||
// Ladestationspezifische Variabeln
|
||||
@@ -38,6 +39,8 @@ class Ladestation_Universal extends IPSModule
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
||||
$this->RegisterVariableInteger("Power", "Power");
|
||||
$this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving");
|
||||
$this->RegisterVariableInteger("Leistung_Delta", "Leistung_Delta", "", 0);
|
||||
$this->RegisterVariableInteger("Power_Count", "Power_Count", "", 0);
|
||||
|
||||
// Hilfsvariabeln für Idle zustand
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
@@ -47,13 +50,15 @@ class Ladestation_Universal extends IPSModule
|
||||
// Initialisiere Idle
|
||||
$this->SetValue("Idle", true);
|
||||
|
||||
$this->RegisterTimer("Timer_Do_UserCalc",5000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");');
|
||||
$this->RegisterTimer("Timer_Do_UserCalc_EVC",$this->ReadPropertyInteger("Interval")*1000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");');
|
||||
|
||||
}
|
||||
|
||||
public function ApplyChanges()
|
||||
{
|
||||
parent::ApplyChanges();
|
||||
$this->SetTimerInterval("Timer_Do_UserCalc_EVC",$this->ReadPropertyInteger("Interval")*1000);
|
||||
|
||||
// Zusätzliche Anpassungen nach Bedarf
|
||||
}
|
||||
|
||||
@@ -82,12 +87,15 @@ class Ladestation_Universal extends IPSModule
|
||||
|
||||
|
||||
|
||||
|
||||
public function SetAktuelle_Leistung(int $power)
|
||||
{
|
||||
|
||||
$internalPower = GetValue($this->GetIDForIdent("Aktuelle_Leistung"));
|
||||
// Aktuelle Leistungsvorgabe setzen
|
||||
SetValue($this->GetIDForIdent("Aktuelle_Leistung"), $power);
|
||||
$this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))));
|
||||
|
||||
if ($power != $internalPower) {
|
||||
// Setze die interne Leistungsvorgabe
|
||||
|
||||
@@ -173,6 +181,8 @@ class Ladestation_Universal extends IPSModule
|
||||
$maxLeistung = $this->ReadPropertyInteger("MaxLeistung");
|
||||
}
|
||||
|
||||
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
// Setze die URL
|
||||
@@ -182,12 +192,28 @@ class Ladestation_Universal extends IPSModule
|
||||
CURLOPT_URL,
|
||||
"http://" . $this->ReadPropertyString("IP_Adresse") . "/api/status"
|
||||
);
|
||||
// Setze die Option, die Antwort als String zurückzugeben
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
// Führe die Anfrage aus und speichere die Antwort
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Schließe cURL
|
||||
curl_close($ch);
|
||||
}elseif($this->ReadPropertyInteger("Ladestation")==1){
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_URL,
|
||||
"http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload="
|
||||
);
|
||||
// Setze die Option, die Antwort als String zurückzugeben
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
// Führe die Anfrage aus und speichere die Antwort
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Schließe cURL
|
||||
curl_close($ch);
|
||||
}
|
||||
elseif($this->ReadPropertyInteger("Ladestation")==3){
|
||||
curl_setopt(
|
||||
@@ -197,10 +223,7 @@ class Ladestation_Universal extends IPSModule
|
||||
);
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $this->ReadPropertyString("Username") . ":" . $this->ReadPropertyString("Password"));
|
||||
}
|
||||
|
||||
|
||||
// Setze die Option, die Antwort als String zurückzugeben
|
||||
// Setze die Option, die Antwort als String zurückzugeben
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
// Führe die Anfrage aus und speichere die Antwort
|
||||
@@ -208,13 +231,20 @@ class Ladestation_Universal extends IPSModule
|
||||
|
||||
// Schließe cURL
|
||||
curl_close($ch);
|
||||
}
|
||||
elseif($this->ReadPropertyInteger("Ladestation")==4){
|
||||
|
||||
$response = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Überprüfe, ob die Antwort nicht leer ist
|
||||
if ($response) {
|
||||
// Dekodiere die JSON-Antwort
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if($this->ReadPropertyInteger("Ladestation")==2||$this->ReadPropertyInteger("Ladestation")==1){
|
||||
if($this->ReadPropertyInteger("Ladestation")==2){
|
||||
// Überprüfe, ob das JSON-Dekodieren erfolgreich war und der Schlüssel "car" existiert
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($data["car"])) {
|
||||
// Speichere den Wert von "car" in der Variable $status
|
||||
@@ -233,6 +263,26 @@ class Ladestation_Universal extends IPSModule
|
||||
}
|
||||
}
|
||||
}
|
||||
if($this->ReadPropertyInteger("Ladestation")==1){
|
||||
// Überprüfe, ob das JSON-Dekodieren erfolgreich war und der Schlüssel "car" existiert
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($data["car"])) {
|
||||
// Speichere den Wert von "car" in der Variable $status
|
||||
|
||||
SetValue(
|
||||
$this->GetIDForIdent("Ladeleistung_Effektiv"),
|
||||
$data["nrg"][11]*10
|
||||
);
|
||||
|
||||
SetValue($this->GetIDForIdent("Fahrzeugstatus"), $data["car"]);
|
||||
|
||||
if ($data["nrg"][6] > 1 && $data["car"] == 2) {
|
||||
SetValue($this->GetIDForIdent("Lademodus"), 1);
|
||||
} elseif ($data["nrg"][6] <= 1 && $data["car"] == 2) {
|
||||
SetValue($this->GetIDForIdent("Lademodus"), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($this->ReadPropertyInteger("Ladestation")==3){
|
||||
// Überprüfe, ob das JSON-Dekodieren erfolgreich war und der Schlüssel "car" existiert
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($data["State"])) {
|
||||
@@ -245,7 +295,7 @@ class Ladestation_Universal extends IPSModule
|
||||
|
||||
SetValue($this->GetIDForIdent("Fahrzeugstatus"), $data["State"]);
|
||||
|
||||
if($data["MaxAllowedChargingCurrent"]>0 && $data["State"] != 1){
|
||||
if(($this->GetValue("Ladeleistung_Effektiv")>0)&& ($data["MaxAllowedChargingCurrent"]>0)){
|
||||
if ($data["ActiveChargingPower"]/$data["MaxAllowedChargingCurrent"] > 0.4/* && $data["State"] != 1*/) {
|
||||
SetValue($this->GetIDForIdent("Lademodus"), 1);
|
||||
} elseif ($data["State"] != 1) {
|
||||
@@ -257,12 +307,46 @@ class Ladestation_Universal extends IPSModule
|
||||
}
|
||||
}
|
||||
}
|
||||
if($this->ReadPropertyInteger("Ladestation")==4){
|
||||
|
||||
// Nichts zu tun hier...
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Peak-Wert speichern
|
||||
$this->SetValue("Peak", $Peak);
|
||||
|
||||
|
||||
IPS_LogMessage("Lades", "Hier");
|
||||
|
||||
$akt = $this->GetValue("Ladeleistung_Effektiv");
|
||||
$pow = $this->GetValue("Aktuelle_Leistung");
|
||||
IPS_LogMessage("akt", $akt);
|
||||
IPS_LogMessage("pow", $pow);
|
||||
|
||||
$timeout = $this->ReadPropertyInteger("Interval")*$this->ReadPropertyInteger("IdleCounterMax")*2;
|
||||
if(($akt<(0.8*$pow)) && ($pow>0)){
|
||||
IPS_LogMessage("Lades", "Hier2");
|
||||
|
||||
$dummy = $this->GetValue("Power_Count")+1;
|
||||
$this->SetValue("Power_Count", $dummy);
|
||||
|
||||
}elseif($this->GetValue("Power_Count")<=$timeout) {
|
||||
IPS_LogMessage("Lades", "Hier3");
|
||||
|
||||
$this->SetValue("Power_Count", 0);
|
||||
|
||||
}
|
||||
IPS_LogMessage("Lades", "Hier4");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Array für die Powersteps initialisieren
|
||||
$powerSteps = [0];
|
||||
|
||||
@@ -284,16 +368,26 @@ class Ladestation_Universal extends IPSModule
|
||||
} elseif ($solarladen && $Peak) {
|
||||
$powerSteps = [0];
|
||||
} else {
|
||||
if($this->GetValue("Power_Count")>$timeout){
|
||||
|
||||
$maxLeistung = 1.05 * $this->GetValue("Ladeleistung_Effektiv");
|
||||
IPS_LogMessage("Lades", "Hier5");
|
||||
|
||||
}
|
||||
|
||||
$powerSteps += $this->getRangeLimits(
|
||||
$minLeistung,
|
||||
$maxLeistung,
|
||||
GetValue($this->GetIDForIdent("Lademodus"))
|
||||
);
|
||||
}
|
||||
}else{
|
||||
|
||||
$this->SetValue("Power_Count", 0);
|
||||
}
|
||||
// PowerSteps in der RegisterVariable speichern
|
||||
SetValue($this->GetIDForIdent("PowerSteps"), json_encode($powerSteps));
|
||||
|
||||
$this->SetValue("Leistung_Delta", $this->GetValue("Ladeleistung_Effektiv")-$this->GetValue("Ladeleistung"));
|
||||
// Rückgabe der Powersteps
|
||||
return $powerSteps;
|
||||
}
|
||||
@@ -304,14 +398,16 @@ class Ladestation_Universal extends IPSModule
|
||||
|
||||
if($this->ReadPropertyInteger("Ladestation")==2){
|
||||
$baseUrl ="http://" . $this->ReadPropertyString("IP_Adresse") . "/api/set?";
|
||||
|
||||
}elseif($this->ReadPropertyInteger("Ladestation")==1){
|
||||
$baseUrl ="http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload=";
|
||||
|
||||
}elseif($this->ReadPropertyInteger("Ladestation")==3){
|
||||
$baseUrl ="https://api.smart-me.com/pico/loadmanagementgroup/current/" . $this->ReadPropertyString("Seriennummer") . "?current=";
|
||||
|
||||
}
|
||||
// Base URL
|
||||
|
||||
IPS_LogMessage("Ladestation", "Aufgerufene ip" . $baseUrl);
|
||||
$value = $this->convertPowerToCurrent(
|
||||
$value,
|
||||
GetValue($this->GetIDForIdent("Lademodus"))
|
||||
@@ -381,7 +477,11 @@ class Ladestation_Universal extends IPSModule
|
||||
|
||||
}elseif($this->ReadPropertyInteger("Ladestation")==3){
|
||||
// Nichts zu tun für Smart-Me station
|
||||
} }elseif($this->ReadPropertyInteger("Ladestation")==4){
|
||||
// Nichts zu tun für Dummy station
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Second request
|
||||
@@ -449,9 +549,11 @@ class Ladestation_Universal extends IPSModule
|
||||
// Return responses
|
||||
return;
|
||||
|
||||
}
|
||||
}elseif($this->ReadPropertyInteger("Ladestation")==4){
|
||||
// Nichts zu tun für Dummy station
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// If value is out of range
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user