Refactoring Manager-User schnittstelle (Andere Variabelnnamen
This commit is contained in:
@@ -6,25 +6,12 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
{
|
||||
parent::Create();
|
||||
|
||||
// Prioritäten
|
||||
$this->RegisterVariableInteger("LockPrio", "LockPrio");
|
||||
$this->RegisterVariableInteger("UserPrio", "UserPrio");
|
||||
|
||||
// Energiehandling
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("CurrentPower", "CurrentPower", "", 0);
|
||||
$this->RegisterVariableFloat("UsedEnergy", "UsedEnergy", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps"); // PowerSteps-Variable registrieren
|
||||
|
||||
// Trägheit system
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
// Boiler spezifische Properties
|
||||
$this->RegisterPropertyInteger("BoilerLeistungTeillast", 3000);
|
||||
$this->RegisterPropertyInteger("BoilerLeistungVolllast", 6000);
|
||||
$this->RegisterPropertyInteger("Boilertemperatur", 0);
|
||||
$this->RegisterPropertyInteger("Kontakt_Teillast", 0);
|
||||
$this->RegisterPropertyInteger("Kontakt_Volllast", 0);
|
||||
|
||||
// Boiler spezifische Variablen
|
||||
$this->RegisterVariableInteger("Boilermintemp","Boilermintemp","",45);
|
||||
@@ -32,11 +19,20 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
$this->RegisterVariableInteger("Boilerlegiotemp","Boilerlegiotemp","",65);
|
||||
$this->RegisterVariableInteger("LegioCounter", "LegioCounter", "", 0);
|
||||
|
||||
// Schaltkontakte
|
||||
$this->RegisterPropertyInteger("Kontakt_Teillast", 0);
|
||||
$this->RegisterPropertyInteger("Kontakt_Volllast", 0);
|
||||
// Variabeln für Kommunkation mit Manager
|
||||
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
|
||||
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
||||
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
||||
|
||||
// Initialisieren
|
||||
// Hilfsvariabeln für Idle zustand
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
// Initialisiere Idle
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
|
||||
@@ -49,8 +45,8 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
public function RequestAction($Ident, $Value)
|
||||
{
|
||||
switch ($Ident) {
|
||||
case "SetCurrentPower":
|
||||
$this->SetCurrentPower($Value);
|
||||
case "SetAktuelle_Leistung":
|
||||
$this->SetAktuelle_Leistung($Value);
|
||||
break;
|
||||
case "GetCurrentData":
|
||||
return $this->GetCurrentData($Value);
|
||||
@@ -60,7 +56,7 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
}
|
||||
|
||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||
public function SetCurrentPower(int $power)
|
||||
public function SetAktuelle_Leistung(int $power)
|
||||
{
|
||||
// Schalte Kontakt Teillast und Vollast entsprechend der Power-Einstellung
|
||||
if ($power == $this->ReadPropertyInteger("BoilerLeistungVolllast")) {
|
||||
@@ -77,7 +73,7 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
}
|
||||
|
||||
// Prüfe auf Änderung der Power im Vergleich zur letzten Einstellung
|
||||
$lastPower = GetValue($this->GetIDForIdent("CurrentPower"));
|
||||
$lastPower = GetValue($this->GetIDForIdent("Aktuelle_Leistung"));
|
||||
if ($power != $lastPower) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue(
|
||||
@@ -86,8 +82,8 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
);
|
||||
}
|
||||
|
||||
// Setze die neue CurrentPower
|
||||
$this->SetValue("CurrentPower", $power);
|
||||
// Setze die neue Aktuelle_Leistung
|
||||
$this->SetValue("Aktuelle_Leistung", $power);
|
||||
|
||||
// IdleCounter verarbeiten
|
||||
$this->ProcessIdleCounter();
|
||||
@@ -184,8 +180,8 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
|
||||
private function CheckIdle($power)
|
||||
{
|
||||
$lastpower = GetValue("CurrentPower");
|
||||
if ($lastpower != GetValue("CurrentPower")) {
|
||||
$lastpower = GetValue("Aktuelle_Leistung");
|
||||
if ($lastpower != GetValue("Aktuelle_Leistung")) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue(
|
||||
"IdleCounter",
|
||||
|
||||
@@ -6,41 +6,37 @@ class Ladestation_Universal extends IPSModule
|
||||
{
|
||||
parent::Create();
|
||||
|
||||
// Prioritäten
|
||||
$this->RegisterVariableInteger("LockPrio", "LockPrio");
|
||||
$this->RegisterVariableInteger("UserPrio", "UserPrio");
|
||||
|
||||
// Energiehandling
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("CurrentPower", "CurrentPower", "", 0);
|
||||
$this->RegisterVariableFloat("UsedEnergy", "UsedEnergy", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps"); // PowerSteps-Variable registrieren
|
||||
|
||||
// Trägheit
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
// Properties registrieren
|
||||
// Ladestationspezifische Properties
|
||||
$this->RegisterPropertyInteger("MinLeistung", 3600);
|
||||
$this->RegisterPropertyInteger("MaxLeistung", 11000);
|
||||
|
||||
$this->RegisterPropertyInteger("MinLeistung_1ph", 1400);
|
||||
$this->RegisterPropertyInteger("MaxLeistung_1ph", 7800);
|
||||
$this->RegisterPropertyString("IP_Adresse", "0.0.0.0");
|
||||
|
||||
// Ladestationspezifische Variabeln
|
||||
$this->RegisterVariableBoolean("Ladebereit", "Ladebereit", "~Switch", 1);
|
||||
$this->RegisterVariableBoolean("Solarladen", "Solarladen", "~Switch", 0);
|
||||
$this->RegisterVariableInteger("Fahrzeugstatus", "Fahrzeugstatus", "", 0);
|
||||
$this->RegisterVariableInteger("Lademodus", "Lademodus", "", 0);
|
||||
$this->RegisterVariableFloat("Ladeleistung_Effektiv", "Ladeleistung_Effektiv", "", 0);
|
||||
|
||||
$this->RegisterVariableBoolean("Peak", "Peak", "", 0);
|
||||
|
||||
$this->RegisterVariableInteger("Ladestrom", "Ladestrom");
|
||||
$this->RegisterVariableInteger("Ladeleistung", "Ladeleistung");
|
||||
|
||||
// Variabeln für Kommunkation mit Manager
|
||||
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
|
||||
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
||||
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
||||
|
||||
// Initialisieren
|
||||
// Hilfsvariabeln für Idle zustand
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
// Initialisiere Idle
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
|
||||
@@ -54,8 +50,8 @@ class Ladestation_Universal extends IPSModule
|
||||
public function RequestAction($Ident, $Value)
|
||||
{
|
||||
switch ($Ident) {
|
||||
case "SetCurrentPower":
|
||||
$this->SetCurrentPower($Value);
|
||||
case "SetAktuelle_Leistung":
|
||||
$this->SetAktuelle_Leistung($Value);
|
||||
break;
|
||||
case "GetCurrentData":
|
||||
$powerSteps = $this->GetCurrentData($Value);
|
||||
@@ -65,11 +61,11 @@ class Ladestation_Universal extends IPSModule
|
||||
}
|
||||
}
|
||||
|
||||
public function SetCurrentPower(int $power)
|
||||
public function SetAktuelle_Leistung(int $power)
|
||||
{
|
||||
$internalPower = GetValue($this->GetIDForIdent("CurrentPower"));
|
||||
$internalPower = GetValue($this->GetIDForIdent("Aktuelle_Leistung"));
|
||||
// Aktuelle Leistungsvorgabe setzen
|
||||
SetValue($this->GetIDForIdent("CurrentPower"), $power);
|
||||
SetValue($this->GetIDForIdent("Aktuelle_Leistung"), $power);
|
||||
if ($power != $internalPower) {
|
||||
// Setze die interne Leistungsvorgabe
|
||||
|
||||
@@ -124,7 +120,7 @@ class Ladestation_Universal extends IPSModule
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Ansonsten setze Ladeleistung auf die aktuelle Leistungsvorgabe (CurrentPower)
|
||||
// Ansonsten setze Ladeleistung auf die aktuelle Leistungsvorgabe (Aktuelle_Leistung)
|
||||
SetValue($this->GetIDForIdent("Ladeleistung"), $power);
|
||||
|
||||
if (GetValue($this->GetIDForIdent("Lademodus")) == 0) {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
},
|
||||
{
|
||||
"type": "List",
|
||||
"name": "EnergyUserList",
|
||||
"name": "Verbraucher_Liste",
|
||||
"caption": "Verbraucher, die gemanagt werden sollen.",
|
||||
"add": true,
|
||||
"delete": true,
|
||||
@@ -32,12 +32,12 @@
|
||||
"columns": [
|
||||
{
|
||||
"caption": "Energieverbraucher",
|
||||
"name": "EnergyUser",
|
||||
"name": "Verbraucher",
|
||||
"width": "auto",
|
||||
"add": 0,
|
||||
"edit": {
|
||||
"type": "SelectInstance",
|
||||
"filter": "EnergyUser"
|
||||
"filter": "Verbraucher"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -10,7 +10,7 @@ class Manager extends IPSModule
|
||||
$this->RegisterPropertyInteger("Peakleistung", 0);
|
||||
$this->RegisterPropertyInteger("Ueberschussleistung", 0);
|
||||
$this->RegisterPropertyInteger("Netzbezug", 0); // Initialisierung mit 0
|
||||
$this->RegisterPropertyString("EnergyUserList", "[]");
|
||||
$this->RegisterPropertyString("Verbraucher_Liste", "[]");
|
||||
|
||||
// Timer registrieren
|
||||
$this->RegisterTimer("Timer_DistributeEnergy",5000,"IPS_RequestAction(" .$this->InstanceID .', "DistributeEnergy", "");');
|
||||
@@ -20,7 +20,7 @@ class Manager extends IPSModule
|
||||
{
|
||||
parent::ApplyChanges();
|
||||
//Liste aller Verbraucher einlesen
|
||||
$energyUserList = $this->ReadPropertyString("EnergyUserList");
|
||||
$Verbraucher_Liste = $this->ReadPropertyString("Verbraucher_Liste");
|
||||
}
|
||||
|
||||
public function RequestAction($Ident, $Value)
|
||||
@@ -54,47 +54,48 @@ class Manager extends IPSModule
|
||||
}
|
||||
|
||||
// Alle Energieverbraucher auslesen und dekodieren
|
||||
$energyUserList = json_decode($this->ReadPropertyString("EnergyUserList"), true);
|
||||
$Verbraucher_Liste = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
||||
|
||||
if (empty($energyUserList)) {
|
||||
if (empty($Verbraucher_Liste)) {
|
||||
// Liste ist leer, daher nichts zu tun
|
||||
return;
|
||||
}
|
||||
|
||||
// Frage alle Energieverbraucher ab, was sie für Leistungen benötigen könnten
|
||||
foreach ($energyUserList as $user) {
|
||||
if (IPS_InstanceExists($user["EnergyUser"])) {
|
||||
IPS_RequestAction($user["EnergyUser"],"GetCurrentData",$Is_Peak_Shaving);
|
||||
foreach ($Verbraucher_Liste as $user) {
|
||||
if (IPS_InstanceExists($user["Verbraucher"])) {
|
||||
IPS_RequestAction($user["Verbraucher
|
||||
"],"GetCurrentData",$Is_Peak_Shaving);
|
||||
}
|
||||
}
|
||||
|
||||
$filteredEnergyUsers = []; // Array das später mit allen Verbrauchsdaten der Energieverbraucher gefüllt wird
|
||||
$filteredVerbrauches = []; // Array das später mit allen Verbrauchsdaten der Energieverbraucher gefüllt wird
|
||||
$allIdle = true; // Variable zur Überprüfung, ob alle Benutzer Idle = true sind
|
||||
$totalCurrentPower = 0; // Variable zur Summierung der CurrentPower Werte
|
||||
$totalAktuelle_Leistung = 0; // Variable zur Summierung der Aktuelle_Leistung Werte
|
||||
|
||||
// Fülle das Array mit allen entsprechenden Werten der Verbraucher ab
|
||||
foreach ($energyUserList as $user) {
|
||||
if (!IPS_InstanceExists($user["EnergyUser"])) {
|
||||
foreach ($Verbraucher_Liste as $user) {
|
||||
if (!IPS_InstanceExists($user["Verbraucher"])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Werte direkt von der EnergyUser-Instanz abrufen
|
||||
$currentPower = GetValue(IPS_GetObjectIDByIdent("CurrentPower", $user["EnergyUser"]));
|
||||
$usedEnergy = GetValue(IPS_GetObjectIDByIdent("UsedEnergy", $user["EnergyUser"]));
|
||||
$userPrio = GetValue(IPS_GetObjectIDByIdent("UserPrio", $user["EnergyUser"]));
|
||||
$lockPrio = GetValue(IPS_GetObjectIDByIdent("LockPrio", $user["EnergyUser"]));
|
||||
$idle = GetValue(IPS_GetObjectIDByIdent("Idle", $user["EnergyUser"]));
|
||||
$powerStepsJson = GetValue(IPS_GetObjectIDByIdent("PowerSteps", $user["EnergyUser"]));
|
||||
// Werte direkt von der Verbraucher-Instanz abrufen
|
||||
$Aktuelle_Leistung = GetValue(IPS_GetObjectIDByIdent("Aktuelle_Leistung", $user["Verbraucher"]));
|
||||
$Bezogene_Energie = GetValue(IPS_GetObjectIDByIdent("Bezogene_Energie", $user["Verbraucher"]));
|
||||
$PV_Prio = GetValue(IPS_GetObjectIDByIdent("PV_Prio", $user["Verbraucher"]));
|
||||
$Sperre_Prio = GetValue(IPS_GetObjectIDByIdent("Sperre_Prio", $user["Verbraucher"]));
|
||||
$idle = GetValue(IPS_GetObjectIDByIdent("Idle", $user["Verbraucher"]));
|
||||
$powerStepsJson = GetValue(IPS_GetObjectIDByIdent("PowerSteps", $user["Verbraucher"]));
|
||||
$powerSteps = json_decode($powerStepsJson, true);
|
||||
|
||||
// EnergyUser-Daten zum gefilterten Array hinzufügen
|
||||
$filteredEnergyUsers[] = [
|
||||
"EnergyUser" => $user["EnergyUser"],
|
||||
"InstanceID" => $user["EnergyUser"],
|
||||
"CurrentPower" => $currentPower,
|
||||
"UsedEnergy" => $usedEnergy,
|
||||
"UserPrio" => $userPrio,
|
||||
"LockPrio" => $lockPrio,
|
||||
// Verbraucher-Daten zum gefilterten Array hinzufügen
|
||||
$filteredVerbrauchers[] = [
|
||||
"Verbraucher" => $user["Verbraucher"],
|
||||
"InstanceID" => $user["Verbraucher"],
|
||||
"Aktuelle_Leistung" => $Aktuelle_Leistung,
|
||||
"Bezogene_Energie" => $Bezogene_Energie,
|
||||
"PV_Prio" => $PV_Prio,
|
||||
"Sperre_Prio" => $Sperre_Prio,
|
||||
"Idle" => $idle,
|
||||
"PowerSteps" => $powerSteps,
|
||||
];
|
||||
@@ -105,48 +106,49 @@ class Manager extends IPSModule
|
||||
}
|
||||
|
||||
// Addiere die aktuell bereits verwendete Leistung auf, um sie bei der verteilung zu berücksichtigen
|
||||
$totalCurrentPower += $currentPower;
|
||||
$totalAktuelle_Leistung += $Aktuelle_Leistung;
|
||||
}
|
||||
// Berücksichtigung der bereits verteilten Leistungen (nachher kann dafür wieder bei 0 begonnen werden zu verteilen)
|
||||
$remainingPower += $totalCurrentPower;
|
||||
$remainingPower += $totalAktuelle_Leistung;
|
||||
|
||||
// Abbrechen wenn es keine gefilterten User gibt
|
||||
if (empty($filteredEnergyUsers)) {
|
||||
if (empty($filteredVerbrauches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Wenn nicht alle Benutzer Idle = true sind, rufe SetCurrentPower mit CurrentPower Werten auf, (alle Verbraucher behalten die aktuelle Leistung)
|
||||
// Wenn nicht alle Benutzer Idle = true sind, rufe SetAktuelle_Leistung mit Aktuelle_Leistung Werten auf, (alle Verbraucher behalten die aktuelle Leistung)
|
||||
if (!$allIdle) {
|
||||
foreach ($filteredEnergyUsers as $user) {
|
||||
IPS_RequestAction($user["InstanceID"],"SetCurrentPower",$user["CurrentPower"]);
|
||||
foreach ($filteredVerbrauchers as $user) {
|
||||
IPS_RequestAction($user["InstanceID"],"SetAktuelle_Leistung",$user["Aktuelle_Leistung"]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Sortiere die Verbruacher nach Priorität entweder der PV_Prio oder der Peak Prio
|
||||
usort($filteredEnergyUsers, function ($a, $b) use (
|
||||
usort($filteredVerbrauches, function ($a, $b) use (
|
||||
$Is_Peak_Shaving
|
||||
) {
|
||||
$primaryKey = $Is_Peak_Shaving ? "LockPrio" : "UserPrio";
|
||||
$primaryKey = $Is_Peak_Shaving ? "Sperre_Prio" : "PV_Prio";
|
||||
// Wenn die Prio geleich ist, sortiere danach welcher verbraucher bisher am wenigsten Energie bekommen hat.
|
||||
if ($a[$primaryKey] == $b[$primaryKey]) {
|
||||
return $a["UsedEnergy"] <=> $b["UsedEnergy"];
|
||||
return $a["Bezogene_Energie"] <=> $b["Bezogene_Energie"];
|
||||
}
|
||||
return $a[$primaryKey] <=> $b[$primaryKey];
|
||||
});
|
||||
|
||||
// Primärschlüssel für die Priorität basierend auf dem Parameter auswählen (für sortierung in gruppen anschliessend)
|
||||
$priorityKey = $Is_Peak_Shaving ? "LockPrio" : "UserPrio";
|
||||
$priorityKey = $Is_Peak_Shaving ? "Sperre_Prio" : "PV_Prio";
|
||||
|
||||
// Schleife durch alle Prioritäten
|
||||
$priorities = array_unique(
|
||||
array_column($filteredEnergyUsers, $priorityKey)
|
||||
array_column($filteredVerbrauchers, $priorityKey)
|
||||
);
|
||||
$groupedUsers = [];
|
||||
|
||||
foreach ($priorities as $priority) {
|
||||
$groupedUsers[$priority] = array_filter(
|
||||
$filteredEnergyUsers,
|
||||
$filteredVerbraucher
|
||||
s,
|
||||
function ($user) use ($priority, $priorityKey) {
|
||||
return $user[$priorityKey] == $priority;
|
||||
}
|
||||
@@ -154,12 +156,12 @@ class Manager extends IPSModule
|
||||
}
|
||||
// Jetzt werden die energien pro gruppe verteilt (Immer alle pro prio in einer gruppe miteinander)
|
||||
foreach ($groupedUsers as $priority => $users) {
|
||||
// EnergyUser mit gleicher Priorität sammeln
|
||||
// Verbraucher mit gleicher Priorität sammeln
|
||||
$samePriorityUsers = isset($groupedUsers[$priority])
|
||||
? $groupedUsers[$priority]
|
||||
: [];
|
||||
|
||||
// Wenn keine EnergyUser mit gleicher Priorität vorhanden sind, überspringen
|
||||
// Wenn keine Verbraucher mit gleicher Priorität vorhanden sind, überspringen
|
||||
if (empty($samePriorityUsers)) {
|
||||
continue;
|
||||
}
|
||||
@@ -179,9 +181,9 @@ class Manager extends IPSModule
|
||||
$instanceID = $entry["InstanceID"];
|
||||
$minPowerStep = min($entry["PowerSteps"]);
|
||||
|
||||
IPS_RequestAction($instanceID,"SetCurrentPower",$minPowerStep
|
||||
IPS_RequestAction($instanceID,"SetAktuelle_Leistung",$minPowerStep
|
||||
);
|
||||
$remainingPower -= $entry["CurrentPower"];
|
||||
$remainingPower -= $entry["Aktuelle_Leistung"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,9 +239,10 @@ class Manager extends IPSModule
|
||||
// Jedem user den höheren der beiden werte aus minimalwert oder vergebenem zuteilen
|
||||
$leistung = max($leistung, $minimalleitsung);
|
||||
|
||||
// Methode SetCurrentPower für jeden EnergyUser mit der entsprechenden Energie aufrufen
|
||||
// Methode SetAktuelle_Leistung für jeden Verbraucher
|
||||
mit der entsprechenden Energie aufrufen
|
||||
if (IPS_InstanceExists($userInstanceID)) {
|
||||
IPS_RequestAction($userInstanceID,"SetCurrentPower",$leistung);
|
||||
IPS_RequestAction($userInstanceID,"SetAktuelle_Leistung",$leistung);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,42 +7,35 @@ class Verbraucher_1_Stufig extends IPSModule
|
||||
{
|
||||
parent::Create();
|
||||
|
||||
// Prioritäten
|
||||
$this->RegisterVariableInteger("LockPrio", "LockPrio");
|
||||
$this->RegisterVariableInteger("UserPrio", "UserPrio");
|
||||
|
||||
// Energiehandling
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableBoolean("IstNacht", "IstNacht", "", 0);
|
||||
$this->RegisterVariableInteger("CurrentPower", "CurrentPower", "", 0);
|
||||
$this->RegisterVariableInteger("DailyOnTime", "DailyOnTime", "", 0);
|
||||
$this->RegisterVariableFloat("UsedEnergy", "UsedEnergy", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps"); // PowerSteps-Variable registrieren
|
||||
|
||||
// Neue Variable für den Timer-Status
|
||||
$this->RegisterVariableBoolean("IsTimerActive", "IsTimerActive", "", 0);
|
||||
$this->SetValue("IsTimerActive", false);
|
||||
|
||||
// Trägheit
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 4);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
// Verbraucherspezifische Properties
|
||||
$this->RegisterPropertyInteger("BoilerLeistung", 6000); // Standardwert für Volllast
|
||||
$this->RegisterPropertyInteger("Mindesttlaufzeit", 4); // Standardwert für Volllast
|
||||
$this->RegisterPropertyInteger("Zeit_Zwischen_Zustandswechseln", 1);
|
||||
$this->RegisterPropertyInteger("Schaltkontakt1", 0);
|
||||
|
||||
// Timer für Zeit_Zwischen_Zustandswechseln
|
||||
$this->RegisterTimer(
|
||||
"ZustandswechselTimer",
|
||||
0,
|
||||
"IPS_RequestAction(" .
|
||||
$this->InstanceID .
|
||||
', "ResetPowerSteps", "");'
|
||||
);
|
||||
// Verbraucherspezifische Variabeln
|
||||
$this->RegisterVariableBoolean("IstNacht", "IstNacht", "", 0);
|
||||
$this->RegisterVariableInteger("DailyOnTime", "DailyOnTime", "", 0);
|
||||
$this->RegisterVariableBoolean("IsTimerActive", "IsTimerActive", "", 0);
|
||||
|
||||
//Initialisieren
|
||||
// Verbraucherspezifischer Timer
|
||||
$this->SetValue("IsTimerActive", false);
|
||||
$this->RegisterTimer("ZustandswechselTimer",0,"IPS_RequestAction(" .$this->InstanceID .', "ResetPowerSteps", "");');
|
||||
|
||||
// Variabeln für Kommunkation mit Manager
|
||||
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
|
||||
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
||||
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
||||
|
||||
// Hilfsvariabeln für Idle zustand
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
// Initialisiere Idle
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
|
||||
@@ -55,8 +48,8 @@ class Verbraucher_1_Stufig extends IPSModule
|
||||
public function RequestAction($Ident, $Value)
|
||||
{
|
||||
switch ($Ident) {
|
||||
case "SetCurrentPower":
|
||||
$this->SetCurrentPower($Value);
|
||||
case "SetAktuelle_Leistung":
|
||||
$this->SetAktuelle_Leistung($Value);
|
||||
break;
|
||||
case "GetCurrentData":
|
||||
return $this->GetCurrentData($Value);
|
||||
@@ -92,7 +85,7 @@ class Verbraucher_1_Stufig extends IPSModule
|
||||
// PowerSteps wieder auf den ursprünglichen Zustand setzen (wie vorherige Funktionalität)
|
||||
$this->SetValue(
|
||||
"PowerSteps",
|
||||
json_encode([$this->GetValue("CurrentPower")])
|
||||
json_encode([$this->GetValue("Aktuelle_Leistung")])
|
||||
);
|
||||
|
||||
// Timer stoppen
|
||||
@@ -102,13 +95,13 @@ class Verbraucher_1_Stufig extends IPSModule
|
||||
$this->SetValue("IsTimerActive", false);
|
||||
}
|
||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||
public function SetCurrentPower(float $power)
|
||||
public function SetAktuelle_Leistung(float $power)
|
||||
{
|
||||
$this->CheckIdle($power);
|
||||
if ($this->GetValue("CurrentPower") != $power) {
|
||||
if ($this->GetValue("Aktuelle_Leistung") != $power) {
|
||||
$this->SetTimerOn();
|
||||
}
|
||||
$this->SetValue("CurrentPower", $power);
|
||||
$this->SetValue("Aktuelle_Leistung", $power);
|
||||
$boilerLeistung = $this->ReadPropertyInteger("BoilerLeistung");
|
||||
$schaltkontaktID = $this->ReadPropertyInteger("Schaltkontakt1");
|
||||
|
||||
@@ -155,7 +148,7 @@ class Verbraucher_1_Stufig extends IPSModule
|
||||
// Timer ist aktiv, PowerSteps setzen
|
||||
$this->SetValue(
|
||||
"PowerSteps",
|
||||
json_encode([$this->GetValue("CurrentPower")])
|
||||
json_encode([$this->GetValue("Aktuelle_Leistung")])
|
||||
);
|
||||
}
|
||||
// Wenn Nacht und Mindestlaufzeit nicht erreicht ist
|
||||
@@ -185,7 +178,7 @@ class Verbraucher_1_Stufig extends IPSModule
|
||||
|
||||
public function CheckIdle($power)
|
||||
{
|
||||
$lastpower = GetValue($this->GetIDForIdent("CurrentPower"));
|
||||
$lastpower = GetValue($this->GetIDForIdent("Aktuelle_Leistung"));
|
||||
if ($lastpower != $power) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter",$this->ReadPropertyInteger("IdleCounterMax"));
|
||||
|
||||
@@ -5,30 +5,7 @@ class WP_Steuerung extends IPSModule
|
||||
{
|
||||
parent::Create();
|
||||
|
||||
// Prioritäten
|
||||
$this->RegisterVariableInteger("LockPrio", "LockPrio");
|
||||
$this->RegisterVariableInteger("UserPrio", "UserPrio");
|
||||
|
||||
// Energiehandling
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", true);
|
||||
$this->RegisterVariableInteger("CurrentPower", "CurrentPower", "", 0);
|
||||
$this->RegisterVariableBoolean("Sperrzeit", "Sperrzeit", "", false);
|
||||
$this->RegisterVariableFloat("UsedEnergy", "UsedEnergy", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps"); // PowerSteps-Variable registrieren
|
||||
|
||||
// Trägheit
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 4);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
$this->RegisterVariableInteger("Mindestlaufzeit", "IdleCounter", "", 0);
|
||||
|
||||
$this->RegisterVariableInteger("Zustand_WP", "Zustand_WP", "", 1);
|
||||
|
||||
$this->RegisterVariableInteger("WP_Laufzeit_Zahler", "WP_Laufzeit_Zahler", "", 20*12);
|
||||
$this->RegisterVariableBoolean("LetzterPeakwert", "LetzterPeakwert", "", false);
|
||||
$this->RegisterVariableBoolean("LetzterPeakwert_Aenderung", "LetzterPeakwert_Aenderung", "", false);
|
||||
|
||||
// WP-Spezifische Properies
|
||||
$this->RegisterPropertyInteger("WP_Leistung", 6000);
|
||||
$this->RegisterPropertyInteger("Wolkenschwellwert", 60);
|
||||
$this->RegisterPropertyInteger("Wolkenwert", 0);
|
||||
@@ -38,9 +15,32 @@ class WP_Steuerung extends IPSModule
|
||||
$this->RegisterPropertyInteger("Kontakt_Erhoeung", 0);
|
||||
$this->RegisterPropertyBoolean("Schwellwert_Anwenden", false);
|
||||
$this->RegisterPropertyInteger("Schwellwert", 0);
|
||||
$this->RegisterPropertyInteger("WW_Temp", 1);
|
||||
$this->RegisterPropertyInteger("WW_Temp", 1);
|
||||
|
||||
//Initialisieren
|
||||
// WP-Spezifische Variabeln
|
||||
$this->RegisterVariableBoolean("Sperrzeit", "Sperrzeit", "", false);
|
||||
$this->RegisterVariableInteger("Mindestlaufzeit", "IdleCounter", "", 0);
|
||||
$this->RegisterVariableInteger("Zustand_WP", "Zustand_WP", "", 1);
|
||||
$this->RegisterVariableInteger("WP_Laufzeit_Zahler", "WP_Laufzeit_Zahler", "", 20*12);
|
||||
$this->RegisterVariableBoolean("LetzterPeakwert", "LetzterPeakwert", "", false);
|
||||
$this->RegisterVariableBoolean("LetzterPeakwert_Aenderung", "LetzterPeakwert_Aenderung", "", false);
|
||||
|
||||
|
||||
|
||||
// Variabeln für Kommunkation mit Manager
|
||||
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
|
||||
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
||||
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
||||
|
||||
// Hilfsvariabeln für Idle zustand
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
// Initialisiere Idle
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ class WP_Steuerung extends IPSModule
|
||||
public function RequestAction($Ident, $Value)
|
||||
{
|
||||
switch ($Ident) {
|
||||
case "SetCurrentPower":
|
||||
$this->SetCurrentPower($Value);
|
||||
case "SetAktuelle_Leistung":
|
||||
$this->SetAktuelle_Leistung($Value);
|
||||
break;
|
||||
case "GetCurrentData":
|
||||
return $this->GetCurrentData($Value);
|
||||
@@ -68,7 +68,7 @@ class WP_Steuerung extends IPSModule
|
||||
}
|
||||
|
||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||
public function SetCurrentPower(float $power)
|
||||
public function SetAktuelle_Leistung(float $power)
|
||||
{
|
||||
$sperrzei_abs =
|
||||
((60 *
|
||||
@@ -122,7 +122,7 @@ class WP_Steuerung extends IPSModule
|
||||
$this->SetValue("WP_Laufzeit_Zahler", 0);
|
||||
SetValue($this->ReadPropertyInteger("Sperrkontakt"), false);
|
||||
} elseif (
|
||||
$this->GetValue("CurrentPower") != $power ||
|
||||
$this->GetValue("Aktuelle_Leistung") != $power ||
|
||||
($this->GetValue("WP_Laufzeit_Zahler") > 240 &&
|
||||
$this->GetValue("LetzterPeakwert") !=
|
||||
$this->GetValue("LetzterPeakwert_Aenderung"))
|
||||
@@ -145,24 +145,24 @@ class WP_Steuerung extends IPSModule
|
||||
) {
|
||||
$this->SetValue("Zustand_WP", 1);
|
||||
$this->SetValue(
|
||||
"CurrentPower",
|
||||
"Aktuelle_Leistung",
|
||||
$this->ReadPropertyInteger("WP_Leistung")
|
||||
);
|
||||
} elseif ($LastPeak && $power == 0) {
|
||||
$this->SetValue("Zustand_WP", 2);
|
||||
$this->SetValue("CurrentPower", 0);
|
||||
$this->SetValue("Aktuelle_Leistung", 0);
|
||||
} elseif (
|
||||
$LastPeak == false &&
|
||||
$power == $this->ReadPropertyInteger("WP_Leistung")
|
||||
) {
|
||||
$this->SetValue("Zustand_WP", 3);
|
||||
$this->SetValue(
|
||||
"CurrentPower",
|
||||
"Aktuelle_Leistung",
|
||||
$this->ReadPropertyInteger("WP_Leistung")
|
||||
);
|
||||
} elseif ($LastPeak == false && $power == 0) {
|
||||
$this->SetValue("Zustand_WP", 1);
|
||||
$this->SetValue("CurrentPower", 0);
|
||||
$this->SetValue("Aktuelle_Leistung", 0);
|
||||
}
|
||||
} elseif ($state == 2) {
|
||||
// Sperre
|
||||
@@ -172,24 +172,24 @@ class WP_Steuerung extends IPSModule
|
||||
) {
|
||||
$this->SetValue("Zustand_WP", 1);
|
||||
$this->SetValue(
|
||||
"CurrentPower",
|
||||
"Aktuelle_Leistung",
|
||||
$this->ReadPropertyInteger("WP_Leistung")
|
||||
);
|
||||
} elseif ($LastPeak && $power == 0) {
|
||||
$this->SetValue("Zustand_WP", 2);
|
||||
$this->SetValue("CurrentPower", 0);
|
||||
$this->SetValue("Aktuelle_Leistung", 0);
|
||||
} elseif (
|
||||
$LastPeak == false &&
|
||||
$power == $this->ReadPropertyInteger("WP_Leistung")
|
||||
) {
|
||||
$this->SetValue("Zustand_WP", 3);
|
||||
$this->SetValue(
|
||||
"CurrentPower",
|
||||
"Aktuelle_Leistung",
|
||||
$this->ReadPropertyInteger("WP_Leistung")
|
||||
);
|
||||
} elseif ($LastPeak == false && $power == 0) {
|
||||
$this->SetValue("Zustand_WP", 1);
|
||||
$this->SetValue("CurrentPower", 0);
|
||||
$this->SetValue("Aktuelle_Leistung", 0);
|
||||
}
|
||||
} elseif ($state == 3) {
|
||||
// Erhöht
|
||||
@@ -199,24 +199,24 @@ class WP_Steuerung extends IPSModule
|
||||
) {
|
||||
$this->SetValue("Zustand_WP", 1);
|
||||
$this->SetValue(
|
||||
"CurrentPower",
|
||||
"Aktuelle_Leistung",
|
||||
$this->ReadPropertyInteger("WP_Leistung")
|
||||
);
|
||||
} elseif ($LastPeak && $power == 0) {
|
||||
$this->SetValue("Zustand_WP", 2);
|
||||
$this->SetValue("CurrentPower", 0);
|
||||
$this->SetValue("Aktuelle_Leistung", 0);
|
||||
} elseif (
|
||||
$LastPeak == false &&
|
||||
$power == $this->ReadPropertyInteger("WP_Leistung")
|
||||
) {
|
||||
$this->SetValue("Zustand_WP", 3);
|
||||
$this->SetValue(
|
||||
"CurrentPower",
|
||||
"Aktuelle_Leistung",
|
||||
$this->ReadPropertyInteger("WP_Leistung")
|
||||
);
|
||||
} elseif ($LastPeak == false && $power == 0) {
|
||||
$this->SetValue("Zustand_WP", 1);
|
||||
$this->SetValue("CurrentPower", 0);
|
||||
$this->SetValue("Aktuelle_Leistung", 0);
|
||||
}
|
||||
} else {
|
||||
$this->SetValue("Zustand_WP", 1);
|
||||
@@ -255,7 +255,7 @@ class WP_Steuerung extends IPSModule
|
||||
|
||||
if($this->GetValue("WP_Laufzeit_Zahler")<(20*12)){
|
||||
|
||||
$this->SetValue("PowerSteps", json_encode([$this->GetValue("CurrentPower")]));
|
||||
$this->SetValue("PowerSteps", json_encode([$this->GetValue("Aktuelle_Leistung")]));
|
||||
|
||||
}elseif($this->ReadPropertyBoolean("Schwellwert_Anwenden")==true && ($this->ReadPropertyInteger("Schwellwert")>GetValue($this->ReadPropertyInteger("WW_Temp"))) ){
|
||||
|
||||
@@ -268,7 +268,7 @@ class WP_Steuerung extends IPSModule
|
||||
|
||||
public function CheckIdle($power)
|
||||
{
|
||||
$lastpower = GetValue($this->GetIDForIdent("CurrentPower"));
|
||||
$lastpower = GetValue($this->GetIDForIdent("Aktuelle_Leistung"));
|
||||
if ($lastpower != $power) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue(
|
||||
|
||||
Reference in New Issue
Block a user