no message
This commit is contained in:
@@ -118,6 +118,14 @@ class Ladestation_v2 extends IPSModule
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "Sperre_Prio":
|
||||||
|
$this->SetValue("Sperre_Prio", (bool)$Value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "PV_Prio":
|
||||||
|
$this->SetValue("PV_Prio", (bool)$Value);
|
||||||
|
break;
|
||||||
|
|
||||||
case "Solarladen":
|
case "Solarladen":
|
||||||
$this->SetValue("Solarladen", (bool)$Value);
|
$this->SetValue("Solarladen", (bool)$Value);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -21,7 +21,13 @@
|
|||||||
"type": "SelectVariable",
|
"type": "SelectVariable",
|
||||||
"name": "Is_Peak",
|
"name": "Is_Peak",
|
||||||
"caption": "Variable zur Signalisierung der Peakleistung",
|
"caption": "Variable zur Signalisierung der Peakleistung",
|
||||||
"suffix": "Sekunden"
|
"suffix": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SelectVariable",
|
||||||
|
"name": "delta_power",
|
||||||
|
"caption": "Variable mit dem Leistungsunterschied",
|
||||||
|
"suffix": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "List",
|
"type": "List",
|
||||||
@@ -51,19 +57,9 @@
|
|||||||
"filter": "Verbraucher"
|
"filter": "Verbraucher"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"caption": "Signal verbracuher ein",
|
|
||||||
"name": "Geschaltet_var",
|
|
||||||
"width": "auto",
|
|
||||||
"add": 0,
|
|
||||||
"edit": {
|
|
||||||
"type": "SelectVariable",
|
|
||||||
"filter": "Verbraucher"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "NumberSpinner",
|
"type": "NumberSpinner",
|
||||||
"name": "Schaltkontakt1",
|
"name": "P_Nenn",
|
||||||
"caption": "Nennleistung des Verbrauchers",
|
"caption": "Nennleistung des Verbrauchers",
|
||||||
"test": true
|
"test": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class Verbraucher_extern extends IPSModule
|
|||||||
// Verbraucherspezifische Properties
|
// Verbraucherspezifische Properties
|
||||||
$this->RegisterPropertyString("Verbraucher_Liste", "");
|
$this->RegisterPropertyString("Verbraucher_Liste", "");
|
||||||
$this->RegisterPropertyInteger("Is_Peak", 0);
|
$this->RegisterPropertyInteger("Is_Peak", 0);
|
||||||
|
$this->RegisterPropertyInteger("delta_power", 0);
|
||||||
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
|
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
|
||||||
|
|
||||||
// Variabeln für Kommunkation mit Manager
|
// Variabeln für Kommunkation mit Manager
|
||||||
@@ -55,10 +56,6 @@ class Verbraucher_extern extends IPSModule
|
|||||||
$this->SetValue("Is_Peak_Shaving", (bool)$Value);
|
$this->SetValue("Is_Peak_Shaving", (bool)$Value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ResetPowerSteps":
|
|
||||||
$this->ResetPowerSteps($Value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "Do_UserCalc":
|
case "Do_UserCalc":
|
||||||
$this->SetAktuelle_Leistung($this->GetValue("Power"));
|
$this->SetAktuelle_Leistung($this->GetValue("Power"));
|
||||||
$this->GetCurrentData($this->GetValue("Is_Peak_Shaving"));
|
$this->GetCurrentData($this->GetValue("Is_Peak_Shaving"));
|
||||||
@@ -72,121 +69,60 @@ class Verbraucher_extern extends IPSModule
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Methode zum Setzen der PowerSteps und Timer starten
|
|
||||||
public function SetTimerOn()
|
|
||||||
{
|
|
||||||
// Timer setzen, der nach "Zeit_Zwischen_Zustandswechseln" abläuft
|
|
||||||
$zeitZwischenZustandswechseln = $this->ReadPropertyInteger(
|
|
||||||
"Zeit_Zwischen_Zustandswechseln"
|
|
||||||
);
|
|
||||||
$this->SetTimerInterval(
|
|
||||||
"ZustandswechselTimer",
|
|
||||||
$zeitZwischenZustandswechseln * 60000
|
|
||||||
); // Timer in Millisekunden
|
|
||||||
IPS_LogMessage("Verbraucher", "In Set Methode");
|
|
||||||
|
|
||||||
// Timer-Status auf true setzen
|
|
||||||
$this->SetValue("IsTimerActive", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methode zum Zurücksetzen von PowerSteps nach Ablauf des Timers
|
|
||||||
public function ResetPowerSteps()
|
|
||||||
{
|
|
||||||
// PowerSteps wieder auf den ursprünglichen Zustand setzen (wie vorherige Funktionalität)
|
|
||||||
$this->SetValue(
|
|
||||||
"PowerSteps",
|
|
||||||
json_encode([$this->GetValue("Aktuelle_Leistung")])
|
|
||||||
);
|
|
||||||
|
|
||||||
// Timer stoppen
|
|
||||||
$this->SetTimerInterval("ZustandswechselTimer", 0);
|
|
||||||
|
|
||||||
// Timer-Status auf false setzen
|
|
||||||
$this->SetValue("IsTimerActive", false);
|
|
||||||
}
|
|
||||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||||
public function SetAktuelle_Leistung(float $power)
|
|
||||||
{
|
public function SetAktuelle_Leistung(float $power) {
|
||||||
$this->CheckIdle($power);
|
$this->CheckIdle($power);
|
||||||
if ($this->GetValue("Aktuelle_Leistung") != $power) {
|
|
||||||
$this->SetTimerOn();
|
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
||||||
|
$kombinationen = $this->kombinationenRekursiv($verbraucherListe, $power);
|
||||||
|
|
||||||
|
// Setze die Werte in Write_Var
|
||||||
|
foreach ($verbraucherListe as $verbraucher) {
|
||||||
|
$writeVarID = $verbraucher['Write_Var'];
|
||||||
|
$pNenn = $verbraucher['P_Nenn'];
|
||||||
|
$this->SetValue($writeVarID, in_array($pNenn, $kombinationen) ? 1 : 0);
|
||||||
|
}
|
||||||
|
$this->SetValue("Leistung_Delta", $power - array_sum($kombinationen));
|
||||||
}
|
}
|
||||||
$this->SetValue("Aktuelle_Leistung", $power);
|
|
||||||
$this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))));
|
|
||||||
|
|
||||||
$boilerLeistung = $this->ReadPropertyInteger("BoilerLeistung");
|
// Methode zum Abrufen der aktuellen Daten
|
||||||
$schaltkontaktID = $this->ReadPropertyInteger("Schaltkontakt1");
|
public function GetCurrentData(bool $Peak)
|
||||||
|
{
|
||||||
|
// Setze die Is_Peak_Shaving Variable
|
||||||
|
$this->SetValue("Is_Peak_Shaving", $Peak);
|
||||||
|
|
||||||
if ($power == $boilerLeistung) {
|
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
||||||
$schaltkontaktStatus = true;
|
$kombinationen = $this->berechneKombinationen($verbraucherListe);
|
||||||
} elseif ($power == 0) {
|
$this->SetValue("PowerSteps", implode(", ", $kombinationen));
|
||||||
$schaltkontaktStatus = false;
|
}
|
||||||
} else {
|
|
||||||
// Keine Änderung, wenn power nicht 0 oder boilerLeistung entspricht
|
private function berechneKombinationen(array $verbraucherListe, float $power = null)
|
||||||
|
{
|
||||||
|
$kombinationen = [];
|
||||||
|
$this->kombinationenRekursiv($verbraucherListe, [], $kombinationen, $power);
|
||||||
|
return $kombinationen;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function kombinationenRekursiv(array $verbraucherListe, array $aktuelleKombi, array &$kombinationen, float $power = null)
|
||||||
|
{
|
||||||
|
if (empty($verbraucherListe)) {
|
||||||
|
$summe = array_sum($aktuelleKombi);
|
||||||
|
if ($power === null || $summe <= $power) {
|
||||||
|
$kombinationen[] = $summe;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentStatus = GetValue($this->ReadPropertyInteger("Schaltkontakt1"));
|
$verbraucher = array_shift($verbraucherListe);
|
||||||
|
if ($this->GetValue($verbraucher['Read_Var']) == 1) {
|
||||||
// Schaltkontaktstatus ändern
|
$this->kombinationenRekursiv($verbraucherListe, array_merge($aktuelleKombi, [$verbraucher['P_Nenn']]), $kombinationen, $power);
|
||||||
SetValue(
|
|
||||||
$this->ReadPropertyInteger("Schaltkontakt1"),
|
|
||||||
$schaltkontaktStatus
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($schaltkontaktStatus) {
|
|
||||||
$this->SetValue("DailyOnTime", $this->GetValue("DailyOnTime") + 1);
|
|
||||||
}
|
}
|
||||||
|
$this->kombinationenRekursiv($verbraucherListe, $aktuelleKombi, $kombinationen, $power);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methode zum Abrufen der aktuellen Daten
|
|
||||||
public function GetCurrentData(bool $Peak)
|
|
||||||
{
|
|
||||||
$IstNacht = $this->GetValue("IstNacht");
|
|
||||||
$NeuesIstNacht = $this->ist_nachts();
|
|
||||||
|
|
||||||
if ($IstNacht == true && $NeuesIstNacht == false) {
|
|
||||||
$this->SetValue("DailyOnTime", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->SetValue("IstNacht", $NeuesIstNacht);
|
|
||||||
|
|
||||||
$DailyOnTime = $this->GetValue("DailyOnTime");
|
|
||||||
$Mindestlaufzeit =
|
|
||||||
$this->ReadPropertyInteger("Mindesttlaufzeit") * 60 * 12;
|
|
||||||
|
|
||||||
// Überprüfen, ob der Timer aktiv ist
|
|
||||||
if ($this->GetValue("IsTimerActive")) {
|
|
||||||
// Timer ist aktiv, PowerSteps setzen
|
|
||||||
$this->SetValue(
|
|
||||||
"PowerSteps",
|
|
||||||
json_encode([$this->GetValue("Aktuelle_Leistung")])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Wenn Nacht und Mindestlaufzeit nicht erreicht ist
|
|
||||||
elseif ($NeuesIstNacht && $DailyOnTime < $Mindestlaufzeit) {
|
|
||||||
if ($Peak) {
|
|
||||||
$this->SetValue(
|
|
||||||
"PowerSteps",
|
|
||||||
json_encode([
|
|
||||||
0,
|
|
||||||
$this->ReadPropertyInteger("BoilerLeistung"),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("PowerSteps",json_encode([$this->ReadPropertyInteger("BoilerLeistung")]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Andernfalls
|
|
||||||
else {
|
|
||||||
if ($Peak) {
|
|
||||||
$this->SetValue("PowerSteps", json_encode([0]));
|
|
||||||
} else {
|
|
||||||
$this->SetValue("PowerSteps",json_encode([0,$this->ReadPropertyInteger("BoilerLeistung"),])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function CheckIdle($power)
|
public function CheckIdle($power)
|
||||||
{
|
{
|
||||||
@@ -205,20 +141,7 @@ class Verbraucher_extern extends IPSModule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function ist_nachts()
|
|
||||||
{
|
|
||||||
date_default_timezone_set("Europe/Berlin"); // Setze hier deine Zeitzone
|
|
||||||
|
|
||||||
$aktuelle_zeit = strtotime(date("H:i")); // Aktuelle Zeit in Stunden und Minuten umwandeln
|
|
||||||
$start_nacht = strtotime("22:00"); // Startzeit der Nacht (22 Uhr)
|
|
||||||
$ende_nacht = strtotime("07:00"); // Endzeit der Nacht (7 Uhr)
|
|
||||||
|
|
||||||
if ($aktuelle_zeit >= $start_nacht || $aktuelle_zeit < $ende_nacht) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user