Mit diesem Script werden die vorhandenen Geräte mit Adresse, Status und Namen angezeigt.
Die im Anhang befindliche Datei in den Ordner scripts kopieren. Im Script die Adresse angeben wo der Bidcos-Servive läuft.
<?
if ($IPS_SENDER == "WebFront") return;
include IPS_GetKernelDir()."scripts\\xmlrpc.inc";
$client = new xmlrpc_client("Homeserver:2001"); // Adresse anpassen
//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, "Auswertung");
$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, "Homematic Interfaces");
}
IPS_SetScriptTimer($IPS_SELF, 900);
}
$abfrage = new xmlrpcmsg("listBidcosInterfaces");
$send = $client->send($abfrage);
$result = php_xmlrpc_decode($send->value());
for($i=0; $i <count($result); $i++)
{
$adresse = CreateVariableByName($parentID, $result[$i]['DESCRIPTION'].": Adresse", 3);
IPS_SetIcon($adresse, "Information");
IPS_SetVariableCustomProfile($adresse, "~String");
SetValue($adresse, $result[$i]['ADDRESS']);
$connect = CreateVariableByName($parentID, $result[$i]['DESCRIPTION'].": Status", 0);
if(!IPS_VariableProfileExists("Status"))
{
IPS_CreateVariableProfile("Status", 0);
IPS_SetVariableProfileAssociation("Status", 1, "Online", "");
IPS_SetVariableProfileAssociation("Status", 0, "Offline", "");
}
$action = IPS_GetVariable($connect);
if($action['VariableCustomAction'] == 0)
{
IPS_SetVariableCustomAction($connect, $IPS_SELF);
IPS_SetIcon($connect, "Information");
IPS_SetVariableCustomProfile($connect, "Status");
}
SetValue($connect, $result[$i]['CONNECTED']);
$default = CreateVariableByName($parentID, $result[$i]['DESCRIPTION'].": Default", 0);
if(!IPS_VariableProfileExists("Default"))
{
IPS_CreateVariableProfile("Default", 0);
IPS_SetVariableProfileAssociation("Default", 1, "Aktiv", "");
IPS_SetVariableProfileAssociation("Default", 0, "Inaktiv", "");
}
$action = IPS_GetVariable($default);
if($action['VariableCustomAction'] == 0)
{
IPS_SetVariableCustomAction($default, $IPS_SELF);
IPS_SetIcon($default, "Information");
IPS_SetVariableCustomProfile($default, "Default");
}
SetValue($default, $result[$i]['DEFAULT']);
}
function CreateVariableByName($id, $name, $type)
{
global $IPS_SELF;
$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;
}
?>
xmlrpc.rar (28.6 KB)