no message

This commit is contained in:
dh
2025-07-03 16:20:10 +02:00
parent 6817dc2bd8
commit 727e4a9ed8
2 changed files with 21 additions and 4 deletions
+5 -1
View File
@@ -37,6 +37,7 @@
</div> </div>
<script> <script>
function Apply(data) { function Apply(data) {
console.log("Neue Daten:", data);
document.getElementById('barCons').style.width = data.prodCons + '%'; document.getElementById('barCons').style.width = data.prodCons + '%';
document.getElementById('barFeed').style.width = data.prodFeed + '%'; document.getElementById('barFeed').style.width = data.prodFeed + '%';
document.getElementById('barPV').style.width = data.consPV + '%'; document.getElementById('barPV').style.width = data.consPV + '%';
@@ -64,11 +65,14 @@
if (typeof registerMessageHandler === 'function') { if (typeof registerMessageHandler === 'function') {
registerMessageHandler(handleMessage); registerMessageHandler(handleMessage);
} else {
console.warn("registerMessageHandler nicht verfügbar");
} }
// Live-Aktualisierung alle 30 Sekunden // Polling: hole alle 30 Sekunden frische Daten
function pollData() { function pollData() {
if (typeof IPS !== 'undefined') { if (typeof IPS !== 'undefined') {
console.log("Poll: RequestAction(update)");
IPS.RequestAction('update', ''); IPS.RequestAction('update', '');
} }
} }
+14 -1
View File
@@ -34,6 +34,7 @@ class PV_Visu extends IPSModule
public function MessageSink($TimeStamp, $SenderID, $Message, $Data) public function MessageSink($TimeStamp, $SenderID, $Message, $Data)
{ {
if ($Message === VM_UPDATE) { if ($Message === VM_UPDATE) {
IPS_LogMessage("PV_Visu", "MessageSink triggered by $SenderID");
$this->UpdateData(); $this->UpdateData();
} }
} }
@@ -48,7 +49,7 @@ class PV_Visu extends IPSModule
public function RequestAction($Ident, $Value) public function RequestAction($Ident, $Value)
{ {
if ($Ident === 'update') { if ($Ident === 'update') {
return $this->UpdateData(); // Rückgabe für Visualisierung return $this->UpdateData();
} }
throw new \Exception("Unknown Ident: $Ident"); throw new \Exception("Unknown Ident: $Ident");
} }
@@ -82,7 +83,11 @@ class PV_Visu extends IPSModule
]; ];
$json = json_encode($data); $json = json_encode($data);
IPS_LogMessage("PV_Visu", "UpdateData: $json");
SetValueString($this->GetIDForIdent('JSONData'), $json); SetValueString($this->GetIDForIdent('JSONData'), $json);
$this->UpdateVisualizationValue($json);
return $data; return $data;
} }
@@ -96,4 +101,12 @@ class PV_Visu extends IPSModule
$values = @AC_GetAggregatedValues($archiveID, $varID, 1, $start, $end, 1); $values = @AC_GetAggregatedValues($archiveID, $varID, 1, $start, $end, 1);
return isset($values[0]['Avg']) ? (float)$values[0]['Avg'] : 0.0; return isset($values[0]['Avg']) ? (float)$values[0]['Avg'] : 0.0;
} }
private function UpdateVisualizationValue(string $json)
{
if (method_exists($this, 'SendDataToVisualization')) {
$this->SendDataToVisualization($json); // nur in IPS >= 7.0
IPS_LogMessage("PV_Visu", "SendDataToVisualization triggered");
}
}
} }