Störungen visualisieren

@Loewenkoenig ja, steht leider ganz schön weit unten auf der ToDo-Liste :frowning:
Es gibt einfach immer wieder zuviele neue Ideen - oder die Altlasten müssen nachgezogen werden.
Das Problem mit Modulen ist … man möchte ja auch das sie funktionieren und muss sie entsprechend pflegen und supporten!
Momentan steht erstmal das Unwetterwarnungs-Script auf dem Migrations-Zettel :slight_smile:

Gruß Heiko

Ne habe es gestern noch hinzugefügt, aber ohne erfolg. Ich schau noch mal heute in Ruhe, mit den Webhook hab ich noch nicht so viel gemacht.

Ich habe gestern mal geschaut und meine Idee war die ID des Scriptes beim Anlegen der Meldung mit zu übergeben, das array hab ich dafür erweitert.
Das hat schon geklappt.

Dann habe ich die Funktion wo Meldeklassen gelöscht werden koopiert und umgeschrieben. Der Plan ist die ID des Skriptes dort zu übergeben an stelle der Meldeklasse.
Die Funktion durchsucht dann alle Meldungen nach der ID des Skriptes und kann dann die Meldung löschen.

Wenn das läuft kann ich es reinstellen, mal sehen ob ich das so gelöst bekomme.

Klingt auch interessant :slightly_smiling_face:

Obwohl ein Meldungsmodul schon eine sehr feine Sache wäre :relaxed: :+1:
Jeder der das Skript bisher benutzt hat, ist begeistert.
Es gibt nichts ähnliches, was diese Möglichkeiten bietet.

Ich habe probleme das ich nicht verstehe was ich anlegen soll als Hook.
im Script ist nur das zu finden.

url: ‚hook/remove?ts=‘ + (new Date()).getTime() + ‚&ScriptID=‘.$_IPS[‚SELF‘].’&number=’.$number.’’ });

Welchen Hook muss ich anlegen ?
In anderen Scripten stand hook\msg aber hier finde ich nix.
Ich habe auch versucht über den Debug zu gehen, aber da steht nie was drin.
Selbst wenn ich drücke auf dem Webfront.

Geofency geht mit dem Hook zeigt aber auch nix im Webhook Debug an… komisch

Hat jemand ein paar Zeilen über Installation des Webhooks für dieses Script für mich :neutral_face:

In Kern Instanzen / WebHook hast du das Script eingetragen?

VG,
Doc

Ja aber welchen Webhook Pfad muss ich nehmen ?

/hook/ oder /hook/msg waren nicht erfolgreich

Hi,
bei mir habe ich /hook/msg

Gruß

Hier wird immer noch auf das alte Script Bezug genommen, da gab es noch den Hook /hook/remove

Nimm lieber das Script von hier (v3.2) Meldungsanzeige im WebFront - #158 von pitti

da ist es dann /hook/msg

Gruß Heiko

Ja damit geht es, aber auch nur mit dem neuen Script.
Vielen Dank
Dann kann ich nun mal etwas einrichten und optimieren

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

Da scheint aber noch etwas nicht zu stimmen?

Wenn ich mit diesem Testcode eine Meldung schreibe, wird diese aber auch nur fortlaufend durchnummeriert und auch der Timer fehlt, mit dem sie sich ggf. selber zurücksetzt …?

$id = 28190;

        $number = IPS_RunScriptWaitEx($id, 
        array(
            'action' => 'add', 
            'text' => 'Testmeldung 3' , 
            'expires' => 1, 
            'removable' => false, 
            'extid' =>12345, 
            'image' => 'Window', 
            'page' => '', 
            'type' => 2 //0 green|1 red|2 yellow|3 blue|4 orange
            ));

das kann sein :rofl:

Das ist so aber stört denn die Nummer ? Wichtig ist das die eindeutige Auslöser ID drin ist und mit dieser kann die richtige Meldung dann auch gelöscht werden ohne die „zufällige Nummer“ zu wissen.

Ich habe meine Fensterkontakte als ereigniss verschaltet.
Fenster auf → Meldung erscheint mit Infos zum Fenster
Fenster zu → Meldung verschwindet wieder

Das ganze hat hier auch mit mehreren Fenster Meldungen geklappt.

Das war doch schon von haus in dem Script gewesen. Da habe ich nix eingebaut.
Ich möchte ja auch genau das nicht, ich möchte wenn die Variable sagt Fenster auf → Meldung mit Namen des Fensters und wenn dann Fenster zu genau diese Meldung löschen.

So sieht das aus bei mir:

Mit meinem Beispiel oben hatte ich ja den Timer mit 1*60 sek angegeben.

'expires' => 1,

Das Hauptscript scheint das aber nicht zu interessieren.
Es wird kein Event angelegt.
Hatte es so verstanden, das die Grundfunktionen noch funktionieren.
Deshalb die Nachfrage.

VG,
Doc

Dann muss ich noch mal schauen was da los ist. Sollte genau so sein aber kann gut sein das es beim basteln weggefallen ist :joy:.

Ja mach das bitte mal, wäre gut wenn diese Funktion noch drin bleiben würde.
Das löschen funktioniert hier jetzt auch, ich hatte übersehen, das du den Syntax dafür abweichend vom Originalscript geändert hattest.

Danke u. viele Grüße,
Doc

Hallo Christian,
ich versuche schon seit einigen Tagen die Meldungen mit Datum und Uhrzeit in einer Zeile auszugeben. Ich schaffe es nur mit dem Icon über des Datums und Uhrzeit! Die linke Spalte ist wohl zu schmal. Ich finde aber die Stelle wo ich dieses ändern kann nicht. Würdest du eventuell dein Script teilen? Wie in Post 26 abgebildet.
dat

lg
Alfred

Sorry für die späte Antwort wenn du mich meinst, wahr 2 Monate Abstinent.

Wenn es für die Autoren in Ordnung ist poste ich hier den Code:

<? 
################################################################################ 
# 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	= 0;
#
# 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	= true;
# Flag, ob Button vor Text angezeigt werden soll;
# nur in Kombi mit NO ICON Flag verwendtbar
$bfort	= true;
#
################################################################################ 

// 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'] : '';
			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);
			}
			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;
	}
	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 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) {
	$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); 
		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%; font-size: 14px;}';
	}
	else {
		$style = $style.'table.msg { width:100%; font-size: 14px; 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(0, 0, 0); background-color: rgb(182, 220, 252);  }';
	$style = $style.'.red { padding: 5px; color: rgb(0, 0, 0); background-color: rgb(255, 100, 80);  }';
	$style = $style.'.green { padding: 5px; color: rgb(0, 0, 0); background-color: rgb(166, 255, 210);  }';
	$style = $style.'.yellow { padding: 5px; color: rgb(0, 0, 0); background-color: rgb(240, 250, 50);  }';
	$style = $style.'.orange { padding: 5px; color: rgb(0, 0, 0); background-color: rgb(255, 190, 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\'></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.");\'><b>OK</b></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.");\'><b>OK</b></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/msg2?ts=\' + (new Date()).getTime() + \'&action=remove&number='.$number.'\' });">OK</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/msg2?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.");\'><b>OK</b></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/msg2?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/msg2?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.");\'><b>OK</b></div></td>';
				}
			}
			$content .= '</tr>';
		}
	}
	$content = $content. '</table>';
	SetValueString($mid, $content);
}

// Fehlerbehandlung
function throwException($message) {
	IPS_LogMessage(IPS_GetName($_IPS['SELF']), 'MSG:'.$message);
}


Hallo Christian, (cbeham),
vielen Dank, aber wie kann man es nur so lange aushalten ohne…
Ich habe das Programm installiert, bekomme aber kein Datum, Uhrzeit und Nummer angezeigt wie in Beitag 26/65 abgebildet.
Ich bekomme es so nicht hin.
Medung2
Meine Ausgabe:
meldung

lg Alfred

Hi Alfred,
wie machst du denn den Eintrag?

Ein Beispiel bei mir:


$timestamp = time();
$uhrzeit = date("H:i", $timestamp);
$datum = date("d.m.Y", $timestamp);

$text1 = "Hallo, dies ist ein Eintrag";

// Meldung eintragen

$text = "</b>".$datum." ".$uhrzeit."</b> <b>".$text1." </b>";
$number = IPS_RunScriptWaitEx(19710, array('action' => 'add', 'text' => $text, 'expires' => time() - 10, 'removable' => true, 'type' => '1')); 
 
# - 'type' (optional): Art der Meldung ... 0 => Info(grün), 1 => Fehler(rot), 2 => Warnung(gelb), 3 => Status(blau)

Hallo Christian,

ich hatte natürlich nur die eine Zeile aus dem Script benutzt! Das ich das Datum und die Zeit mit übernehmen mußte war mir nicht bewußt! Jetzt geht es!!
Vielen Dank!