private function RefreshLinks()
 {
     if ($this->ReadPropertyInteger("LinkSource") == 0) {
         foreach (IPS_GetChildrenIDs($this->InstanceID) as $Child) {
             if (IPS_GetObject($Child)['ObjectType'] == 6) {
                 IPS_DeleteLink($Child);
             }
         }
         return;
     }
     $present = array();
     foreach (IPS_GetChildrenIDs($this->InstanceID) as $Child) {
         if (IPS_GetObject($Child)['ObjectType'] == 6) {
             $present[] = IPS_GetLink($Child)['TargetID'];
         }
     }
     $create = array_diff(IPS_GetChildrenIDs($this->ReadPropertyInteger("LinkSource")), $present);
     foreach ($create as $Target) {
         if (IPS_GetObject($Target)["ObjectIsHidden"]) {
             continue;
         }
         $Link = IPS_CreateLink();
         IPS_SetParent($Link, $this->InstanceID);
         IPS_SetName($Link, IPS_GetName($Target));
         IPS_SetLinkTargetID($Link, $Target);
     }
 }
             echo "--------------------------------------------------------------------" . PHP_EOL;
         }
     }
     if (is_string($Mapping[$Obj['ObjectIdent']]['Action'])) {
         IPS_SetVariableCustomAction($Var, GetOrCreateScript($ScriptCat, $Mapping[$Obj['ObjectIdent']]['Action']));
     }
     $DeviceHidden = false;
     // Link erzeugen zu Gewerk wenn Mapping nicht leer ist
     if ($Mapping[$Obj['ObjectIdent']]['Name Gewerk'] == '') {
         continue;
     }
     //
     // Schleife Gewerk
     foreach ($Channel->{'Function'} as $Function) {
         $Name = sprintf($Mapping[$Obj['ObjectIdent']]['Name Gewerk'], utf8_decode((string) $Channel['Name']), utf8_decode((string) $Channel->Room[0]['Name']), utf8_decode((string) $Function['Name']));
         $LnkID = IPS_CreateLink();
         IPS_SetLinkTargetID($LnkID, $Var);
         IPS_SetName($LnkID, $Name);
         IPS_SetParent($LnkID, $Functions[utf8_decode((string) $Function['Name'])]);
     }
 } else {
     IPS_SetHidden($Var, true);
 }
 if (in_array($Obj['ObjectIdent'], $Emulate)) {
     IPS_SetProperty($HMDevice, 'EmulateStatus', true);
     usleep(50000);
     IPS_ApplyChanges($HMDevice);
 }
 if (in_array($Obj['ObjectIdent'], $RequestState)) {
     @HM_RequestStatus($HMDevice, $Obj['ObjectIdent']);
 }
Exemple #3
0
 protected function CreateLink($Ident, $Name, $Target = 0)
 {
     if (!($LinkID = @IPS_GetObjectIdByIdent($Ident, $this->InstanceID))) {
         $LinkID = IPS_CreateLink();
         IPS_SetName($LinkID, $Name);
         IPS_SetParent($LinkID, $this->InstanceID);
         IPS_SetIdent($LinkID, $Ident);
         if ($Target) {
             IPS_SetLinkTargetID($LinkID, $Target);
             $EventID = IPS_CreateEvent(0);
             IPS_SetParent($EventID, $this->InstanceID);
             // $LinkID);
             IPS_SetEventTrigger($EventID, 1, $Target);
             IPS_SetEventScript($EventID, 'PJ_UpdateColor($_IPS[\'TARGET\']);');
         }
     }
 }