Ich habe mal fix was gebastelt für das XML-API CCU Addon, was zum alten Befehl kompatibel ist und theoretisch als austausch genutzt werden könnte.
Achtung, ich habe noch nicht die neuste Version im Einsatz, die dann auch Authentification untersützt.
function HMIP_ReadServiceMessages($id)
{
//Vorraussetzung XML-API CCU Addon für CCU. https://github.com/homematic-community/XML-API
//Getestet bis Version 1.22
// Konfiguration der Instanz als JSON-String auslesen
// Parameter 'Host' ermitteln
$configJSON = IPS_GetConfiguration($id);
$configArray = json_decode($configJSON, true);
if(isset($configArray['Host'])) {
$HomeMaticHostIP = $configArray['Host'];
}
//systemNotification auslesen
$URL = "http://". $HomeMaticHostIP ."/addons/xmlapi/systemNotification.cgi";
$xmlString = Sys_GetURLContent($URL);
$xmlObjekt = simplexml_load_string($xmlString);
if($xmlObjekt === false)
die("Verbindung zur CCU fehlgeschlagen");
foreach ($xmlObjekt as $SystemNotification) {
$msg = $SystemNotification->attributes();
$msgaddress = (explode(".", $msg["name"]))[1];
$msgtype = (explode(".", $msg["name"]))[2];
$Message = [
"Address" => $msgaddress,
"Message" => $msgtype,
"Value" => 1
];
$msgs[] = $Message;
}
return $msgs;
}
Hier noch ein Vorschlag-Skript, was ich im Einsatz habe. Ist relativ einfach gestrikt. Für mich reicht es aber. Ich meine das habe ich auch mal irgendwann von hier kopiert. Leider habe ich die Quelle nicht mehr.
<?php
//Erstellt eine Variable die im WebFront alle ServiceMeldungen anzeigt. Einfach in ein Skript kopieren und ausführen.
//Ab hier nichts mehr ändern
$object = IPS_GetObject($_IPS['SELF']);
$parentID = $object['ParentID'];
//Installer
if ($_IPS['SENDER'] == "Execute")
{
IPS_SetHidden($_IPS['SELF'], true);
IPS_SetName($_IPS['SELF'], "Auslese-Skript");
$parentObject = IPS_GetObject($parentID);
if ($parentObject['ObjectType'] !== 1)
{
$instanceID = IPS_CreateInstance("{485D0419-BE97-4548-AA9C-C083EB82E61E}");
IPS_SetParent($instanceID, $parentID);
$parentID = $instanceID;
IPS_SetParent($_IPS['SELF'], $parentID);
IPS_SetName($instanceID, "Servicemeldungen");
}
IPS_SetScriptTimer($_IPS['SELF'], 300);
}
$texte = Array(
"CONFIG_PENDING" => "Konfigurationsdaten stehen zur Übertragung an",
"LOWBAT" => "Batterieladezustand gering",
"LOW_BAT" => "Batterieladezustand gering",
"STICKY_UNREACH" => "Gerätekommunikation war gestört",
"UNREACH" => "Gerätekommunikation aktuell gestört"
);
$str = "<table width='90%' align='center'>"; // Farbe anpassen oder style entfernen
$str .= "<tr><td><b>Gerätname</b></td><td><b>GeräteID</b></td><td><b>Meldung</b></td></tr>";
//HomeMatic Socket Verbindung zu Hommatic testen
$ids = IPS_GetInstanceListByModuleID("{A151ECE9-D733-4FB9-AA15-7F7DD10C58AF}");
if(sizeof($ids) == 0)
die("Keine HomeMatic Socket Instanz gefunden!");
#$msgs = HM_ReadServiceMessages($ids[0]);
$msgs = HMIP_ReadServiceMessages($ids[0]);
if($msgs === false)
die("Verbindung zur CCU fehlgeschlagen");
if(sizeof($msgs) == 0)
$str .= "<tr><td colspan=3><br/>Keine Servicemeldungen!</td></tr>";
foreach($msgs as $msg)
{
//print_r($msg['Message']."\n");
if($msg['Message'] != 'UNREACH'){
//print_r($msg['Message']."\n");
if(array_key_exists($msg['Message'], $texte)) {
$text = $texte[$msg['Message']];
} else {
$text = $msg['Message'];
}
$id = GetInstanceIDFromHMID($msg['Address']);
if(IPS_InstanceExists($id)) {
$name = IPS_GetLocation($id);
} else {
$name = "Gerät nicht in IP-Symcon eingerichtet";
}
// Kategorie für nicht genutzte aber noch vorhandene oder nicht abgelernte Geräte.
if (strpos($name, "Hardware\Reserve\\") === 0) {
//print_r("$name wird ignoriert, aktuell nicht genutzt."."\n");
}
else {
//print_r($name."\n");
$str .= "<tr><td>".$name."</td><td>".$msg['Address']."</td><td>".$text."</td></tr>";
}
}
}
$str .= "</table>";
$vid = CreateVariableByName($parentID, "Content", 3);
IPS_SetIcon($vid, "Information");
IPS_SetVariableCustomProfile($vid, "~HTMLBox");
SetValue($vid, $str);
function GetInstanceIDFromHMID($sid)
{
$ids = IPS_GetInstanceListByModuleID("{EE4A81C6-5C90-4DB7-AD2F-F6BBD521412E}");
foreach($ids as $id)
{
$a = explode(":", IPS_GetProperty($id, 'Address'));
$b = explode(":", $sid);
if($a[0] == $b[0])
{
return $id;
}
}
return 0;
}
function CreateVariableByName($id, $name, $type)
{
$vid = @IPS_GetVariableIDByName($name, $id);
if($vid === false)
{
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
}
return $vid;
}
function HMIP_ReadServiceMessages($id)
{
//Vorraussetzung XML-API CCU Addon für CCU. https://github.com/homematic-community/XML-API
//Getestet bis Version 1.22
// Konfiguration der Instanz als JSON-String auslesen
// Parameter 'Host' ermitteln
$configJSON = IPS_GetConfiguration($id);
$configArray = json_decode($configJSON, true);
if(isset($configArray['Host'])) {
$HomeMaticHostIP = $configArray['Host'];
}
//systemNotification auslesen
$URL = "http://". $HomeMaticHostIP ."/addons/xmlapi/systemNotification.cgi";
$xmlString = Sys_GetURLContent($URL);
$xmlObjekt = simplexml_load_string($xmlString);
if($xmlObjekt === false)
die("Verbindung zur CCU fehlgeschlagen");
foreach ($xmlObjekt as $SystemNotification) {
$msg = $SystemNotification->attributes();
$msgaddress = (explode(".", $msg["name"]))[1];
$msgtype = (explode(".", $msg["name"]))[2];
$Message = [
"Address" => $msgaddress,
"Message" => $msgtype,
"Value" => 1
];
$msgs[] = $Message;
}
return $msgs;
}
?>