umbau der energiemenge, manager rundet jetzt auf 2kwh dadurch wird integratepower nicht mehr benötigt.

This commit is contained in:
2025-03-17 15:56:00 +01:00
parent 99b93484bf
commit e78a9f9a09
8 changed files with 8 additions and 81 deletions

View File

@@ -37,7 +37,6 @@ class Batterie extends IPSModule
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
$this->RegisterVariableFloat("Bezogene_Energie_Zwischenwert", "Bezogene_Energie_Zwischenwert", "", 0);
// Hilfsvariabeln für Idle zustand
$this->RegisterPropertyInteger("IdleCounterMax", 2);
@@ -61,20 +60,6 @@ class Batterie extends IPSModule
$this->SetTimerInterval("Timer_Do_UserCalc_Battery",$this->ReadPropertyInteger("Interval")*1000);
}
public function IntegratePower() {
if (rand(1, 1000) === 1) { // 0.1% Chance
$this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))));
$this->SetValue("Bezogene_Energie_Zwischenwert", 0);
}else{
$this->SetValue("Bezogene_Energie_Zwischenwert", $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600)));
}
return; // Falls nichts gespeichert wird
}
private function GeneratePowerSteps($additionalValue)
{
@@ -192,7 +177,7 @@ public function RequestAction($Ident, $Value)
// Setze die neue aktuelle Leistung
$this->SetValue("Aktuelle_Leistung", $power);
$this->IntegratePower();
$this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))));
// IdleCounter verarbeiten
$this->ProcessIdleCounter();