Auf Asynchron umgebaut

This commit is contained in:
2025-01-22 08:40:12 +01:00
parent 75eef3411d
commit c2c0b34bad
7 changed files with 143 additions and 49 deletions

View File

@@ -36,6 +36,8 @@ class Ladestation_Universal extends IPSModule
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
$this->RegisterVariableString("PowerSteps", "PowerSteps");
$this->RegisterVariableInteger("Power", "Power");
$this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving");
// Hilfsvariabeln für Idle zustand
$this->RegisterPropertyInteger("IdleCounterMax", 2);
@@ -44,6 +46,9 @@ class Ladestation_Universal extends IPSModule
// Initialisiere Idle
$this->SetValue("Idle", true);
$this->RegisterTimer("Timer_Do_UserCalc",5000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");');
}
public function ApplyChanges()
@@ -52,16 +57,24 @@ class Ladestation_Universal extends IPSModule
// Zusätzliche Anpassungen nach Bedarf
}
// Aktionen verarbeiten
public function RequestAction($Ident, $Value)
{
switch ($Ident) {
case "SetAktuelle_Leistung":
$this->SetAktuelle_Leistung($Value);
SetValue("Power", $Value);
break;
case "GetCurrentData":
$powerSteps = $this->GetCurrentData($Value);
return $powerSteps;
SetValue("Is_Peak_Shaving", $Value);
break;
case "Do_UserCalc":
$this->SetAktuelle_Leistung(GetValue("Power"));
$this->GetCurrentData(GetValue("Is_Peak_Shaving"));
break;
default:
throw new Exception("Invalid Ident");
}