Ich habe die Tage mal etwas rumgespielt.
Ich habe das Scritp erweitert und übergebe die ID des „Meldeobjektes“ und speichere sie in der Meldung. Beim löschen suche ich nach dieser ID und kann die Meldung dann auch löschen.
Bei mir geht das ganz gut.
Das Meldescript ist bei mir mit vielen Ereignissen versehen die Meldungen erzeugen und löschen.
Masterscript:
<?php
################################################################################
# Scriptbezeichnung: System.Dashboard.ips.php
# Version: 3.0.20190221
# Author: Heiko Wilknitz (@Pitti)
# Original von Horst (12.11.2010)
# Angepasst für RasPi lueralba (31.3.2015)
#
# Meldungsanzeige im WebFront!
# Dieses Skript dient zur Verwaltung einer Meldungsliste im WebFront.
# Meldungen können hinzugefügt und entfernt werden. Es ist auch möglich,
# Meldungen zu einem bestimmten Zeitpunkt automatisch löschen zu lassen,
# sowie das Löschen von Meldungen durch Klick im WebFront zu aktivieren.
# Mit der Version 2.0 ist es möglich den Button zum Wechseln der Seite
# im Webfront zu benutzen (Typ 4).
#
# ------------------------------ Installation ----------------------------------
#
# Dieses Skript richtet automatisch alle nötigen Objekte bei manueller
# Ausführung ein. Eine weitere manuelle Ausführung setzt alle benötigten Objekte
# wieder auf den Ausgangszustand.
#
# - Neues Skript erstellen
# - Diesen PHP-Code hineinkopieren
# - Skript Abspeichern
# - Webfront ID eintragen (Abschnitt 'Konfiguration')
# - Skript Ausführen
#
# Meldung durch ein anderes Skript hinzufügen lassen:
# ---------------------------------------------------
#
# $number = IPS_RunScriptWaitEx(ObjektID, array('action' => 'add', 'text' => 'Test', 'expires' => time() + 60, 'removable' => true));
# Die Rückgabe des Aufrufes ist die Identifikationsnummer der neuen Nachricht,
# bei Misserfolg wird der Wert 0 zurückgegeben.
#
# Parameter:
# - 'text': Meldungstext
# - 'expires' (optional): Zeitpunkt des automatischen Löschens der Meldung
# als Unix-Timestamp. Ist der Wert kleiner als die aktuelle Timestamp,
# wird nicht automatisch gelöscht.
# - 'removable' (optional): Meldung wird bei Klick auf Button gelöscht.
# - 'type' (optional): Art der Meldung ... 0 => Normal(grün),
# 1 => Fehler(rot), 2 => Warnung(gelb), 3 => Todo(blau), 4 => Goto(orange)
# - 'image' (optional): Name des WebFront-Icons (ipsIcon<name>), welches
# für Meldung verwendet werden soll, Standard ist "Talk"
# Doku: https://www.symcon.de/service/dokumentation/komponenten/icons/
# z.B. Clock, Gear, Alert, etc....
# - 'page' (optional): Nur in Verbindung mit Type 4 - Seitenname
# HINWEIS: funktioniert nur ohne Parameter 'removable'!!
#
# Meldung durch ein anderes Skript löschen lassen:
# ------------------------------------------------
#
# $success = IPS_RunScriptWaitEx(ObjektID, array('action' => 'remove', 'number' => 123));
# Bei erfolgreichem Löschen wird der Wert 1 zurückgegeben, bei Misserfolg der Wert 0.
#
# Parameter:
# - 'number': Identifikationsnummer der zu löschenden Meldung
#
# Meldung eines bestimmten Types löschen:
# ------------------------------------------------
#
# $success = IPS_RunScriptWaitEx(ObjektID, array('action' => 'removeType', 'type' => x));
# Bei erfolgreichem Löschen wird der Wert 1 zurückgegeben, bei Misserfolg der Wert 0.
#
# Parameter:
# - 'type': Meldungstyp der gelöscht werden soll (x = 0|1|2|3|4)
#
# Alle vorhandenen Meldungen durch ein anderes Skript löschen lassen:
# -------------------------------------------------------------------
#
# $success = IPS_RunScriptWaitEx(ObjektID, array('action' => 'removeAll'));
# Bei erfolgreichem Löschen wird der Wert 1 zurückgegeben, bei Misserfolg der Wert 0.
#
# Eine Meldungen hinzufügen, welche bei Klick auf den Button die Seite wechselt:
# ------------------------------------------------------------------------------
#
# $id = IPS_RunScriptWaitEx(ObjektID , array('action' => 'add', 'text' => $text, 'type' => 4, 'image' => 'Telephone', 'page' => 'catAnrufe'));
# Der Parameter 'page' definiert zu welcher Seite im Webfront gewechselt werden soll.
# Der Name der Seite muss einer existierenden 'Element ID' im konfigurierten Webfront
# entsprechen (z.b. item32435).
#
# ------------------------------ Changelog -------------------------------------
#
# 08.02.2017 - Initalversion (v1.0)
# 17.02.2018 - Neuer Typ 4 zum Wechseln der Seite bei Klick auf Button
# Umstellung auf Webhook als Ersatz für extra Remove-Script (v2.0)
# 24.02.2018 - über 'fifo' kann man die Reihenfolge der Meldungsausgabe steuern
# - der Zeitstemmpel wann die Meldung erzeugt wurde wird beim Hover
# über das Icon angezeigt
# Doku verbessert (v2.1)
# 26.02.2018 - Flag für Reihenfolge der Meldungsauflistung hinzugefügt (v2.2)
# 04.03.2018 - Hinterlegung einer URL auf den Button (eperimental) (v2.3)
# 21.02.2019 - 3 neue Flags füre die Manupilation der Darstellung hinzugefügt
# 'nomsg' für keine Meldungen, 'noico' für keine Icons und
# 'bfort' für Button vor Text (in Kombi mit NO-ICON) (v3.0)
#
# ----------------------------- Konfigruration ---------------------------------
#
# WebFront Configuration
$wfc = 19682;
#
# First In First Out - erste Meldung wird zuerst dargestellt, sonst
# letzte Meldung zuerst (LIFO).
$fifo = false;
# Flag, ob angezeigt werden soll das keine Meldung existiert.
$nomsg = true;
# Flag, ob Icons angezeigt werden soll.
$noico = false;
# Flag, ob Button vor Text angezeigt werden soll;
# nur in Kombi mit NO ICON Flag verwendbar
$bfort = false;
#
################################################################################
// INSTALLATION
if ($_IPS['SENDER']=='Execute') {
install();
}
// SCRIPTAUSFUEHRUNG
else if($_IPS['SENDER'] == "RunScript") {
$result = 0;
switch ($_IPS['action']) {
case 'add':
$expires = isset($_IPS['expires']) ? $_IPS['expires'] : 0;
$removable = isset($_IPS['removable']) ? $_IPS['removable'] : false;
$text = isset($_IPS['text']) ? $_IPS['text'] : 'leer';
$type = isset($_IPS['type']) ? $_IPS['type'] : 0;
$image = isset($_IPS['image']) ? $_IPS['image'] : 'Talk';
$page = isset($_IPS['page']) ? $_IPS['page'] : '';
$extid = isset($_IPS['extid']) ? $_IPS['extid'] : '';
if (!($expires > time())) { $expires = 0; }
if (!($removable === true)) { $removable = false; }
if (!($type > 0)) { $type = 0; }
if (!(is_string($page))) { $page = ''; }
if (!($image != '')) { $image = 'Talk'; }
if (is_string($text) && $text != '') {
$result = addMessage($text, $expires, $removable, $type, $image, $page, $extid);
}
break;
case 'remove':
$number = isset($_IPS['number']) ? $_IPS['number'] : -1;
if ($number > 0) {
$result = removeMessage($number);
}
break;
case 'removeAll':
$result = removeAllMessages();
break;
case 'removeType':
$type = isset($_IPS['type']) ? $_IPS['type'] : -1;
if ($type >= 0) {
$result = removeTypes($type);
}
break;
case 'removeEXTID':
$extid = isset($_IPS['extid']) ? $_IPS['extid'] : -1;
if ($extid >= 0) {
$result = removeEXTID($extid);
}
break;
}
echo $result;
}
// TIMER EVENT
else if($_IPS['SENDER'] == "TimerEvent") {
$number = explode('#', IPS_GetName($_IPS['EVENT']));
$number = $number[1];
IPS_DeleteEvent($_IPS['EVENT']);
removeMessage($number);
}
// AUFRUF WEBHOOK
else if($_IPS['SENDER'] == "WebHook") {
$result = 0;
switch ($_GET['action']) {
case 'remove':
$number = isset($_GET['number']) ? $_GET['number'] : -1;
if ($number > 0) {
$result = removeMessage($number);
}
break;
case 'switch':
$page = isset($_GET['page']) ? $_GET['page'] : '';
if (is_string($page) && $page !='') {
$split = explode(',',$page);
$result = switchPage($wfc, $split[0]);
if(isset($split[1]) && ($split[1] != '')) {
sendPopup($wfc, $split[1]);
}
}
break;
}
echo $result;
}
# ------------------------------ Funktionen ------------------------------------
// Alle Meldungen(Daten) löschen und Letzte Meldungsnummer auf 0 setzen
function removeAllMessages () {
$pid = IPS_GetParent($_IPS['SELF']);
$did = IPS_GetVariableIDByName('Daten', $pid);
$mid = IPS_GetVariableIDByName('Meldungen', $pid);
$lid = IPS_GetVariableIDByName('letzte Meldungsnummer', $pid);
$ids = IPS_GetChildrenIDs($_IPS['SELF']);
foreach ($ids as $id) {
if (IPS_EventExists($id) && substr(IPS_GetName($id), 0, 16) == 'Remove Message #') {
IPS_DeleteEvent($id);
}
}
SetValueString($did, json_encode(array()));
SetValueString($mid, 'Keine Meldungen vorhanden!');
SetValueInteger($lid, 0);
return 1;
}
// Alle Meldungen eines bestimmten Meldungstyp löschen.
function removeTypes($type) {
$pid = IPS_GetParent($_IPS['SELF']);
$did = IPS_GetVariableIDByName('Daten', $pid);
$result = 0;
$i = 0;
$j = 0;
$data = json_decode(GetValueString($did), true);
foreach($data as $id => $val) {
if($val['type'] == $type) {
if(removeMessage($id)) $i++;
$j++;
}
}
if ($i == $j) $result = 1;
return $result;
}
// Meldung einer bestimmten ID löschen.
function removeEXTID($extid) {
$pid = IPS_GetParent($_IPS['SELF']);
$did = IPS_GetVariableIDByName('Daten', $pid);
$result = 0;
$i = 0;
$j = 0;
$data = json_decode(GetValueString($did), true);
foreach($data as $id => $val) {
if($val['extid'] == $extid) {
if(removeMessage($id)) $i++;
$j++;
}
}
if ($i == $j) $result = 1;
return $result;
}
// Meldung mit der Meldungsnummer(number) löschen.
function removeMessage($number) {
$pid = IPS_GetParent($_IPS['SELF']);
$did = IPS_GetVariableIDByName('Daten', $pid);
$result = 0;
if (IPS_SemaphoreEnter($_IPS['SELF'].'DataUpdate', 2000)) {
$data = json_decode(GetValueString($did), true);
if (isset($data[$number])) {
unset($data[$number]);
$eid = @IPS_GetEventIDByName('Remove Message #'.$number, $_IPS['SELF']);
if ($eid !== false) {
IPS_DeleteEvent($eid);
}
SetValueString($did, json_encode($data));
$result = 1;
}
else {
throwException('Could not remove message #'.$number.': Unknown message number!');
}
IPS_SemaphoreLeave($_IPS['SELF'].'DataUpdate');
renderData($data);
}
else {
throwException('Could not remove message #'.$number.': Semaphore timeout!');
}
return $result;
}
// Neue Meldung hinzufügen
function addMessage ($text, $expires, $removable, $type, $image, $page, $extid) {
$pid = IPS_GetParent($_IPS['SELF']);
$did = IPS_GetVariableIDByName('Daten', $pid);
$lid = IPS_GetVariableIDByName('letzte Meldungsnummer', $pid);
$number = 0;
if (IPS_SemaphoreEnter($_IPS['SELF'].'DataUpdate', 2000)) {
$data = json_decode(GetValueString($did), true);
if (!is_array($data)) {
$data = array();
}
$number = GetValueInteger($lid) + 1;
$data[$number] = array('timestamp' => time(), 'text' => utf8_encode($text), 'expires' => $expires, 'removable' => $removable, 'type' => $type, 'image' => $image, 'page' => $page, 'extid' => $extid);
if ($expires > time()) {
$eid = IPS_CreateEvent(1);
IPS_SetParent($eid, $_IPS['SELF']);
IPS_SetName($eid, 'Remove Message #'.$number);
IPS_SetEventCyclic($eid, 1, 0, 0, 0, 0, 0);
if($expires == 0) {
IPS_SetEventCyclicDateFrom($eid, 0, 0, 0);
} else {
IPS_SetEventCyclicDateFrom($eid, (int)date('j',$expires), (int)date('n', $expires), (int)date('Y', $expires));
}
IPS_SetEventCyclicDateTo($eid, 0, 0, 0);
if($expires == 0) {
IPS_SetEventCyclicTimeFrom($eid, 0, 0, 0);
} else {
IPS_SetEventCyclicTimeFrom($eid, (int)date("H", $expires), (int)date("i", $expires), (int)date("s", $expires));
}
IPS_SetEventCyclicTimeTo($eid, 0, 0, 0);
IPS_SetEventActive($eid, true);
}
SetValueString($did, json_encode($data));
SetValueInteger($lid, $number);
IPS_SemaphoreLeave($_IPS['SELF'].'DataUpdate');
renderData($data);
}
else {
throwException('Could not add message: Semaphore timeout!');
}
return $number;
}
// Umschalten zu einer bestimmten Seite im WebFront
function switchPage($wfc, $page) {
$result = WFC_SwitchPage($wfc, $page);
return $result;
}
// Popup öffnen für Link-Anzeige (experimental)
function sendPopup($wfc, $url) {
$result = WFC_SendPopup($wfc, 'Weiterleitung', "<a href='".$url."'>KLICK</a>");
return $result;
}
// Installationsroutine zum Erzeugen aller notwendigen Variablen.
function install () {
$pid = IPS_GetParent($_IPS['SELF']);
$iid = 0;
if (IPS_InstanceExists($pid)) {
$instance = IPS_GetInstance($pid);
if ($instance['ModuleInfo']['ModuleID'] == '{485D0419-BE97-4548-AA9C-C083EB82E61E}') {
$iid = $pid;
}
}
if ($iid == 0) {
$iid = IPS_CreateInstance('{485D0419-BE97-4548-AA9C-C083EB82E61E}');
IPS_SetParent($iid, $pid);
IPS_SetName($iid, 'Meldungen');
IPS_SetParent($_IPS['SELF'], $iid);
$pid = $iid;
}
$did = @IPS_GetVariableIDByName('Daten', $pid);
if ($did === false) {
$did = IPS_CreateVariable(3);
IPS_SetParent($did, $pid);
IPS_SetName($did, 'Daten');
}
SetValueString($did, json_encode(array()));
$mid = @IPS_GetVariableIDByName('Meldungen', $pid);
if ($mid === false) {
$mid = IPS_CreateVariable(3);
IPS_SetParent($mid, $pid);
IPS_SetName($mid, 'Meldungen');
IPS_SetVariableCustomProfile($mid, '~HTMLBox');
}
$lid = @IPS_GetVariableIDByName('letzte Meldungsnummer', $pid);
if ($lid === false) {
$lid = IPS_CreateVariable(1);
IPS_SetParent($lid, $pid);
IPS_SetName($lid, 'letzte Meldungsnummer');
}
SetValueInteger($lid, 0);
$ids = IPS_GetChildrenIDs($_IPS['SELF']);
foreach ($ids as $id) {
if (IPS_EventExists($id) && substr(IPS_GetName($id), 0, 16) == 'Remove Message #') {
IPS_DeleteEvent($id);
}
}
renderData(array());
}
// Meldungen als HTML zusammenbauen.
function renderData ($data) {
global $fifo, $nomsg, $noico, $bfort;
$pid = IPS_GetParent($_IPS['SELF']);
$mid = IPS_GetVariableIDByName('Meldungen', $pid);
$cnt = count($data);
// Etwas CSS und HTML
$style = "";
$style = $style.'<style type="text/css">';
if($cnt == 0 && $nomsg) {
$style = $style.'table.msg { width:100%;}';
}
else {
$style = $style.'table.msg { width:100%; border-collapse: collapse; }';
}
if($noico) {
if($bfort) {
$style = $style.'td.fst { width: 42px; text-align:center; padding: 2px; border-left: 1px solid rgba(255, 255, 255, 0.2); border-top: 1px solid rgba(255, 255, 255, 0.1); }';
$style = $style.'td.lst { padding: 5px; border-right: 1px solid rgba(255, 255, 255, 0.2); border-top: 1px solid rgba(255, 255, 255, 0.1); }';
}
else {
$style = $style.'td.fst { padding: 5px; border-left: 1px solid rgba(255, 255, 255, 0.2); border-top: 1px solid rgba(255, 255, 255, 0.1); }';
$style = $style.'td.lst { width: 42px; text-align:center; padding: 2px; border-right: 1px solid rgba(255, 255, 255, 0.2); border-top: 1px solid rgba(255, 255, 255, 0.1); }';
}
}
else {
$style = $style.'td.fst { width: 36px; padding: 2px; border-left: 1px solid rgba(255, 255, 255, 0.2); border-top: 1px solid rgba(255, 255, 255, 0.1); }';
$style = $style.'td.mid { padding: 2px; border-top: 1px solid rgba(255, 255, 255, 0.1); }';
$style = $style.'td.lst { width: 42px; text-align:center; padding: 2px; border-right: 1px solid rgba(255, 255, 255, 0.2); border-top: 1px solid rgba(255, 255, 255, 0.1); }';
}
$style = $style.'tr:last-child { border-bottom: 1px solid rgba(255, 255, 255, 0.2); }';
$style = $style.'.blue { padding: 5px; color: rgb(255, 255, 255); background-color: rgb(0, 0, 255); background-image: linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -o-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -moz-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -webkit-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -ms-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); }';
$style = $style.'.red { padding: 5px; color: rgb(255, 255, 255); background-color: rgb(255, 0, 0); background-image: linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -o-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -moz-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -webkit-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -ms-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); }';
$style = $style.'.green { padding: 5px; color: rgb(255, 255, 255); background-color: rgb(0, 255, 0); background-image: linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -o-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -moz-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -webkit-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -ms-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); }';
$style = $style.'.yellow { padding: 5px; color: rgb(255, 255, 255); background-color: rgb(255, 255, 0); background-image: linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -o-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -moz-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -webkit-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -ms-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); }';
$style = $style.'.orange { padding: 5px; color: rgb(255, 255, 255); background-color: rgb(255, 160, 0); background-image: linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -o-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -moz-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -webkit-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); background-image: -ms-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0.3) 50%,rgba(0,0,0,0.3) 100%); }';
$style = $style.'</style>';
$content = $style;
$content = $content.'<table class="msg">';
if ($cnt == 0) {
// Keine Meldung, dann sagen wir das auch ;-)
if(!$nomsg) {
$content = $content.'<tr>';
$class = 'fst';
// Icon?
if(!$noico) {
$content = $content.'<td class="fst"><img src=\'img/icons/Ok.svg\'>OK </img></td>';
$class = 'mid';
}
// Button vor Text
if($noico && $bfort) {
$content = $content.'<td class=\'fst\'><div class=\'green\' onclick=\'alert("Nachricht kann nicht bestätigt werden.");\'>OK K</div></td>';
$content = $content.'<td class=\'"lst\'>Keine Meldungen vorhanden!</td>';
}
// Button nach Text
else {
$content = $content.'<td class=\''.$class.'\'>Keine Meldungen vorhanden!</td>';
$content = $content.'<td class=\'lst\'><div class=\'green\' onclick=\'alert("Nachricht kann nicht bestätigt werden.");\'>OK </div></td>';
}
$content = $content.'</tr>';
}
// Keine Meldung, keine Ausgabe
else {
$content = $content.'<tr><td></td></tr>';
}
}
else {
// fifo or lifo
if(!$fifo) {
$data = array_reverse($data, true);
}
foreach ($data as $number => $message) {
if ($message['type']) {
switch ($message['type']) {
case 4:
$type = 'orange';
break;
case 3:
$type = 'blue';
break;
case 2:
$type = 'yellow';
break;
case 1:
$type = 'red';
break;
default:
$type = 'green';
break;
}
}
else {
$type = 'green';
}
if ($message['image']) {
$title = ' ';
if (isset($message['timestamp'])) {
$title .= 'title=\''.date("d.m.Y H:i", $message['timestamp']).'\' ';
}
$image = '<img src=\'img/icons/'.$message['image'].'.svg\''.$title.'></img>';
}
else {
$image = '<img src=\'img/icons/Ok.svg\'></img>';
}
$content .= '<tr>';
$class = 'fst';
// Icon?
if(!$noico) {
$content = $content.'<td class="fst">'.$image.'</td>';
$class = 'mid';
}
// Button vor Text
if($noico && $bfort) {
if ($message['removable']) {
$content = $content.'<td class=\'fst\'><div class=\''.$type.'\' onclick="window.xhrGet=function xhrGet(o) {var HTTP = new XMLHttpRequest();HTTP.open(\'GET\',o.url,true);HTTP.send();};window.xhrGet({ url: \'hook/msg?ts=\' + (new Date()).getTime() + \'&action=remove&number='.$number.'\' });"></div> </td>';
}
elseif ($message['page']) {
$content = $content.'<td class=\'fst\'><div class=\''.$type.'\' onclick="window.xhrGet=function xhrGet(o) {var HTTP = new XMLHttpRequest();HTTP.open(\'GET\',o.url,true);HTTP.send();};window.xhrGet({ url: \'hook/msg?ts=\' + (new Date()).getTime() + \'&action=switch&page='.$message['page'].'\' });">OK </div></td>';
}
else {
$content = $content.'<td class=\'fst\'><div class=\''.$type.'\' onclick=\'alert("Nachricht kann nicht bestätigt werden.");\'>OK </div></td>';
}
$content = $content.'<td class="lst">'.utf8_decode($message['text']).'</td>';
}
// Button nach Text
else {
$content = $content.'<td class="'.$class.'">'.utf8_decode($message['text']).'</td>';
if ($message['removable']) {
$content = $content.'<td class=\'lst\'><div class=\''.$type.'\' onclick="window.xhrGet=function xhrGet(o) {var HTTP = new XMLHttpRequest();HTTP.open(\'GET\',o.url,true);HTTP.send();};window.xhrGet({ url: \'hook/msg?ts=\' + (new Date()).getTime() + \'&action=remove&number='.$number.'\' });">OK </div></td>';
}
elseif ($message['page']) {
$content = $content.'<td class=\'lst\'><div class=\''.$type.'\' onclick="window.xhrGet=function xhrGet(o) {var HTTP = new XMLHttpRequest();HTTP.open(\'GET\',o.url,true);HTTP.send();};window.xhrGet({ url: \'hook/msg?ts=\' + (new Date()).getTime() + \'&action=switch&page='.$message['page'].'\' });">OK </div></td>';
}
else {
$content = $content.'<td class=\'lst\'><div class=\''.$type.'\' onclick=\'alert("Nachricht kann nicht bestätigt werden.");\'> </div></td>';
}
}
$content .= '</tr>';
}
}
$content = $content. '</table>';
SetValueString($mid, $content);
}
// Fehlerbehandlung
function throwException($message) {
IPS_LogMessage(IPS_GetName($_IPS['SELF']), 'MSG:'.$message);
}
################################################################################
?>
Meldescript
<?php
if($_IPS['SENDER'] == 'Variable'){
$id = 28268;
if ($_IPS['VALUE'] == false)
{
$parent = IPS_GetParent($_IPS['VARIABLE']);
$parentname = IPS_GetName($parent);
$number = IPS_RunScriptWaitEx($id,
array(
'action' => 'add',
'text' => $parentname .' - Fenster oder Tür ist geöffnet! Heizung wird abgeschaltet.' ,
'expires' => -1,
'removable' => false,
'extid' =>$_IPS['VARIABLE'],
'image' => 'Window',
'page' => '',
'type' => 2 //0 green|1 red|2 yellow|3 blue|4 orange
));
}
else
{
$success = IPS_RunScriptWaitEx($id, array('action' => 'removeEXTID', 'extid' =>$_IPS['VARIABLE']));
}
}
Kann eigentlich jemand mit HTML gut um, ich hätte gerne nicht nur den Button in der Farbe der Meldung sondern die Reihe der Tabelle auch. geht das ?
Viel spaß beim testen.
Gruß Daniel