What can we improve?

Dokumentation

Translation is in progress...

Not all topics are available at the moment and content links may be broken.

HM_ReadServiceMessages

array HM_ReadServiceMessages (integer $InstanceID)

Parameters

InstanceID ID of the HomeMatic Socket Instance

Returns

The following information are available as key => value pairs:

Index Type Description
Address string Address of the relevant device
Message string Cryptic description of the error message. Text can be found partially in the stringtable_de.txt from the Home Automatic configuration tool.
Value variant Value of the error message

Description

Reads the service news of the CCU/ LAN adapter with the ID InstanceID.

Example

//Creates a variable that displays all service messages in the WebFront. Copy in a script and run.
 
//From here change anything
$object = IPS_GetObject($_IPS['SELF']);
$parentID = $object['ParentID'];
 
//Installer
if ($_IPS['SENDER'] == "Execute")
{
    IPS_SetHidden($_IPS['SELF'], true);
    IPS_SetName($_IPS['SELF'], "Script");
    $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, "Servic messages");
    }
    IPS_SetScriptTimer($_IPS['SELF'], 300);
}
 
$texte = Array(
    "CONFIG_PENDING" => "Configuration data are due for transfer",
    "LOWBAT" => "Low battery condition",
    "STICKY_UNREACH" => "Device communication was disrupted",
    "UNREACH" => "Disrupted communication devices currently"
);
 
$str = "<table width='90%' align='center'>"; // Adjust color or remove style
$str .= "<tr><td><b>Gerätname</b></td><td><b>GeräteID</b></td><td><b>Meldung</b></td></tr>";
 
$ids = IPS_GetInstanceListByModuleID("{A151ECE9-D733-4FB9-AA15-7F7DD10C58AF}");
if(sizeof($ids) == 0)
    die("No HomeMatic Socket instance found!");
 
$msgs = HM_ReadServiceMessages($ids[0]);
if($msgs === false)
    die("Connect to the CCU failed");
 
if(sizeof($msgs) == 0)
    $str .= "<tr><td colspan=3><br/>No service messages!</td></tr>";
 
foreach($msgs as $msg)
{
    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 = "Device is not set up in IP Symcon";
    }
 
    $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(":", HM_GetAddress($id));
        $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);
        IPS_SetInfo($vid, "this variable was created by script #".$_IPS['SELF']);
    }
    return $vid;
}
Deutsche Webseite verfügbar
Go to cart
Any questions?