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

@@ -21,7 +21,11 @@ class Batterie extends IPSModule
$this->RegisterVariableString("PowerSteps", "PowerSteps");
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
$this->RegisterVariableInteger("Power", "Power");
$this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving");
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
// Hilfsvariabeln für Idle zustand
@@ -31,6 +35,10 @@ class Batterie extends IPSModule
// Initialisiere Idle
$this->SetValue("Idle", true);
$this->RegisterTimer("Timer_Do_UserCalc",5000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");');
}
public function ApplyChanges()
@@ -56,19 +64,28 @@ class Batterie extends IPSModule
public function RequestAction($Ident, $Value)
{
switch ($Ident) {
case "SetAktuelle_Leistung":
$this->SetAktuelle_Leistung($Value);
break;
case "GetCurrentData":
return $this->GetCurrentData($Value);
default:
throw new Exception("Invalid Ident");
}
public function RequestAction($Ident, $Value)
{
switch ($Ident) {
case "SetAktuelle_Leistung":
SetValue("Power", $Value);
break;
case "GetCurrentData":
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");
}
}
public function SetAktuelle_Leistung(int $power)
{