no message
This commit is contained in:
@@ -91,56 +91,12 @@ class Batterie extends IPSModule
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->RegisterMessageWatchMaxValues();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function RegisterMessageWatchMaxValues()
|
|
||||||
{
|
|
||||||
// alte Watcher entfernen (falls sich die ausgewählten Variablen geändert haben)
|
|
||||||
$old = json_decode($this->GetBuffer("WatchMaxIDs") ?: "[]", true);
|
|
||||||
if (is_array($old)) {
|
|
||||||
foreach ($old as $oid) {
|
|
||||||
$oid = (int)$oid;
|
|
||||||
if ($oid > 0 && IPS_VariableExists($oid)) {
|
|
||||||
$this->UnregisterMessage($oid, VM_UPDATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// neue IDs aus den Properties holen (SelectVariable => Variable-ID)
|
|
||||||
$idMaxBat = (int)$this->ReadPropertyInteger("MaxBatterieleistung");
|
|
||||||
$idMaxNach = (int)$this->ReadPropertyInteger("MaxNachladen");
|
|
||||||
|
|
||||||
$new = [];
|
|
||||||
foreach ([$idMaxBat, $idMaxNach] as $id) {
|
|
||||||
if ($id > 0 && IPS_VariableExists($id)) {
|
|
||||||
$this->RegisterMessage($id, VM_UPDATE);
|
|
||||||
$new[] = $id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->SetBuffer("WatchMaxIDs", json_encode($new));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function MessageSink($TimeStamp, $SenderID, $Message, $Data)
|
|
||||||
{
|
|
||||||
if ($Message !== VM_UPDATE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$watch = json_decode($this->GetBuffer("WatchMaxIDs") ?: "[]", true);
|
|
||||||
if (!is_array($watch)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array((int)$SenderID, array_map('intval', $watch), true)) {
|
|
||||||
// sofort neu berechnen
|
|
||||||
$this->GetCurrentData($this->GetValue("Is_Peak_Shaving"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private function GeneratePowerSteps($additionalValue)
|
private function GeneratePowerSteps($additionalValue)
|
||||||
|
|||||||
Reference in New Issue
Block a user