V1.0 Stable

This commit is contained in:
2025-01-22 11:12:05 +01:00
parent 7856853146
commit 05be791fde
8 changed files with 137 additions and 74 deletions

View File

@@ -29,18 +29,6 @@
"caption": "Minimum des Batterieladezustand",
"suffix": ""
},
{
"type": "SelectVariable",
"name": "Entladestrom",
"caption": "Entladestrom",
"test": true
},
{
"type": "SelectVariable",
"name": "Ladestrom",
"caption": "Ladestrom",
"test": true
},
{
"type": "SelectVariable",
"name": "Batterieladezustand",

View File

@@ -12,18 +12,21 @@ class Batterie extends IPSModule
$this->RegisterPropertyInteger("AufdasNachladen",0);
$this->RegisterPropertyInteger("MinimumEntladen",0);
$this->RegisterPropertyInteger("Batterieladezustand",0);
$this->RegisterPropertyInteger("Ladestrom", 0);
$this->RegisterPropertyInteger("Entladestrom", 0);
// Variabeln für Kommunkation mit Manager
$this->RegisterVariableProfile("Batterie.Leistung", 1, "W");
$this->RegisterVariableProfile("Batterie.Strom", 1, "A");
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "Batterie.Leistung", 0);
$this->RegisterVariableFloat("Ladestrom", "Ladestrom", "", 0);
$this->RegisterVariableFloat("Entladestrom", "Entladestrom", "", 0);
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
$this->RegisterVariableString("PowerSteps", "PowerSteps");
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "Batterie.Leistung", 0);
$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
$this->RegisterPropertyInteger("IdleCounterMax", 2);
@@ -32,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()
@@ -55,35 +62,39 @@ class Batterie extends IPSModule
return $array_powersteps;
}
private function RegisterVariableProfile(string $name, int $type, string $suffix)
public function RequestAction($Ident, $Value)
{
if (!IPS_VariableProfileExists($name)) {
IPS_CreateVariableProfile($name, $type);
IPS_SetVariableProfileText($name, "", $suffix);
switch ($Ident) {
case "SetAktuelle_Leistung":
$this->SetValue("Power", (int)$Value);
break;
case "GetCurrentData":
$this->SetValue("Is_Peak_Shaving", (bool)$Value);
break;
case "Do_UserCalc":
$this->SetAktuelle_Leistung($this->GetValue("Power"));
$this->GetCurrentData($this->GetValue("Is_Peak_Shaving"));
break;
default:
throw new Exception("Invalid Ident");
}
}
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 SetAktuelle_Leistung(int $power)
{
$batterieladezustand = $this->ReadPropertyInteger("Batterieladezustand"); // Als Property gelesen
$maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); // Als Property gelesen
$spannung = $this->ReadPropertyInteger("Batteriespannung"); // Spannung ebenfalls als Property
$ladestrom = $this->ReadPropertyInteger("Ladestrom");
$entladestrom = $this->ReadPropertyInteger("Entladestrom");
$ladestrom = GetValue($this->GetIDForIdent("Ladestrom"));
$entladestrom = GetValue($this->GetIDForIdent("Entladestrom"));
IPS_LogMessage("Batterie", "power: " . $power);