no message
This commit is contained in:
+2
-6
@@ -37,7 +37,6 @@
|
|||||||
</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 + '%';
|
||||||
@@ -65,18 +64,15 @@
|
|||||||
|
|
||||||
if (typeof registerMessageHandler === 'function') {
|
if (typeof registerMessageHandler === 'function') {
|
||||||
registerMessageHandler(handleMessage);
|
registerMessageHandler(handleMessage);
|
||||||
} else {
|
|
||||||
console.warn("registerMessageHandler nicht verfügbar");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Polling: hole alle 30 Sekunden frische Daten
|
// Live-Aktualisierung alle 30 Sekunden
|
||||||
function pollData() {
|
function pollData() {
|
||||||
if (typeof IPS !== 'undefined') {
|
if (typeof IPS !== 'undefined') {
|
||||||
console.log("Poll: RequestAction(update)");
|
|
||||||
IPS.RequestAction('update', '');
|
IPS.RequestAction('update', '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setInterval(pollData, 30000);
|
setInterval(pollData, 30000);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+17
-32
@@ -30,14 +30,27 @@ class PV_Visu extends IPSModule
|
|||||||
|
|
||||||
$this->UpdateData(); // Initial
|
$this->UpdateData(); // Initial
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function MessageSink($TimeStamp, $SenderID, $Message, $Data)
|
||||||
|
{
|
||||||
|
if ($Message === VM_UPDATE) {
|
||||||
|
$this->UpdateData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetVisualizationTile()
|
||||||
|
{
|
||||||
|
$initialData = '<script>handleMessage(' . json_encode($this->UpdateData()) . ');</script>';
|
||||||
|
$html = file_get_contents(__DIR__ . '/module.html');
|
||||||
|
return $html . $initialData;
|
||||||
|
}
|
||||||
|
|
||||||
public function RequestAction($Ident, $Value)
|
public function RequestAction($Ident, $Value)
|
||||||
{
|
{
|
||||||
if ($Ident === 'update') {
|
if ($Ident === 'update') {
|
||||||
$data = $this->UpdateData();
|
return $this->UpdateData(); // Rückgabe für Visualisierung
|
||||||
return $data; // ← sendet Daten direkt an die Visualisierung
|
|
||||||
}
|
}
|
||||||
throw new Exception("Unknown Ident: $Ident");
|
throw new \Exception("Unknown Ident: $Ident");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UpdateData()
|
public function UpdateData()
|
||||||
@@ -70,28 +83,8 @@ class PV_Visu extends IPSModule
|
|||||||
|
|
||||||
$json = json_encode($data);
|
$json = json_encode($data);
|
||||||
SetValueString($this->GetIDForIdent('JSONData'), $json);
|
SetValueString($this->GetIDForIdent('JSONData'), $json);
|
||||||
|
|
||||||
// Kein SendDataToVisualization!
|
|
||||||
IPS_LogMessage("PV_Visu", "UpdateData (JSON): $json");
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
public function MessageSink($TimeStamp, $SenderID, $Message, $Data)
|
|
||||||
{
|
|
||||||
if ($Message === VM_UPDATE) {
|
|
||||||
IPS_LogMessage("PV_Visu", "MessageSink triggered by $SenderID");
|
|
||||||
$this->UpdateData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetVisualizationTile()
|
|
||||||
{
|
|
||||||
$initialData = '<script>handleMessage(' . json_encode($this->UpdateData()) . ');</script>';
|
|
||||||
$html = file_get_contents(__DIR__ . '/module.html');
|
|
||||||
return $html . $initialData;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function GetDailyTotal(int $varID, int $start, int $end)
|
private function GetDailyTotal(int $varID, int $start, int $end)
|
||||||
{
|
{
|
||||||
@@ -103,12 +96,4 @@ 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user