protected function HideOrDeaktiv(bool $hidden) { if ($this->ReadPropertyBoolean("Invert")) { $hidden = !$hidden; } if ($this->ReadPropertyInteger("Target") == 0) { echo "Target invalid."; return; } $Target = $this->ReadPropertyInteger("Target"); if (!IPS_ObjectExists($Target)) { echo "Target invalid."; return; } if ($this->ReadPropertyInteger("TargetType") == 0) { $this->SetHiddenOrDisabled($Target, $hidden); } elseif ($this->ReadPropertyInteger("TargetType") == 1) { $Source = $this->ReadPropertyInteger("Source"); $Childs = IPS_GetChildrenIDs($Target); foreach ($Childs as $Child) { if ($Child == $Source) { continue; } if (IPS_GetObject($Child)['ObjectType'] == 6) { if (IPS_GetLink($Child)['TargetID'] == $Source) { continue; } } $this->SetHiddenOrDisabled($Child, $hidden); } } else { echo "TargetType invalid."; return; } }
function Entertainment_PowerOffUnusedDevices() { IPSLogger_Trc(__file__, 'Power Off unused Devices ...'); $ActiveDeviceNames = get_ActiveDeviceNames(); $DeviceIds = IPS_GetChildrenIDs(c_ID_Devices); foreach ($DeviceIds as $DeviceId) { $DeviceName = IPS_GetName($DeviceId); $PowerId = get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower, false); if ($PowerId !== false) { if (GetValue($PowerId) and !array_key_exists($DeviceName, $ActiveDeviceNames)) { Entertainment_SetDevicePowerByDeviceName($DeviceName, false); } } } }
function Migrate_Category($categoryId, $filePath) { foreach (IPS_GetChildrenIDs($categoryId) as $idx=>$childId) { $object = IPS_GetObject($childId); switch($object['ObjectType']) { case 0: // Category case 1: // Instance Migrate_Category($childId, $filePath); break; case 3: // Script Delete_Script($childId, $filePath); break; default: // Ignore } } }
function WinLIRC_ReceiveData_Variable($VariableId, $Value) { if ($Value == "") { return; } $Button = $Value; $InstanceId = IPS_GetParent($VariableId); $ChildrenIds = IPS_GetChildrenIDs($InstanceId); foreach ($ChildrenIds as $Id) { if ($Id <> $VariableId) { $RemoteControl = GetValue($Id); } } IPSLogger_Com(__file__, "Received Data from WinLIRC-Variable, Control='$RemoteControl', Command='$Button'"); $MessageType = get_MessageTypeByControl($RemoteControl); WinLIRC_ReceiveData($RemoteControl, $Button, $MessageType); }
protected function HideOrDeaktiv(bool $hidden) { if ($this->ReadPropertyBoolean("Invert")) { $hidden = !$hidden; } // Links erzeugen / prüfen wird nur bei ApplyChanges gemacht $Source = $this->ReadPropertyInteger("Source"); $Childs = IPS_GetChildrenIDs($this->InstanceID); foreach ($Childs as $Child) { if (IPS_GetObject($Child)['ObjectType'] != 6) { continue; } if (IPS_GetLink($Child)['TargetID'] == $Source) { continue; } $this->SetHiddenOrDisabled($Child, $hidden); } }
private function processChilds($childCategory, $state) { $childs = IPS_GetChildrenIDs($childCategory); foreach ($childs as $child) { $link = @IPS_GetLink($child); if ($link) { $variableID = $link["TargetID"]; $variableObject = IPS_GetObject($variableID); $variable = IPS_GetVariable($variableID); $ipsValue = $state; // request associated action for the specified variable and value if ($variable["VariableCustomAction"] > 0) { IPS_RunScriptEx($variable["VariableCustomAction"], array("VARIABLE" => $variableID, "VALUE" => $ipsValue)); } else { IPS_RequestAction($variableObject["ParentID"], $variableObject["ObjectIdent"], $ipsValue); } } } }
function Entertainment_SetRoomVisible($PowerId, $Value) { $RoomConfig = get_RoomConfiguration(); $RoomId = IPS_GetParent($PowerId); $RoomName = IPS_GetName($RoomId); $WFRoomName = $RoomConfig[$RoomName][c_Property_Name]; if ($WFRoomName=="") return; $WFRoomId = IPS_GetCategoryIDByName($WFRoomName, c_ID_WebFrontRoomes); $ChildrenIds = IPS_GetChildrenIDs($WFRoomId); foreach($ChildrenIds as $ChildrenIdx => $ChildrenId) { if (IPS_LinkExists($ChildrenId)) { $LinkData = IPS_GetLink($ChildrenId); $LinkedChildId = $LinkData["LinkChildID"]; if ($LinkedChildId <> $PowerId) { IPSLogger_Trc(__file__, 'Set Control "'.IPS_GetName($ChildrenId).'" of Room "'.IPS_GetName($RoomId).'" Visible='.bool2OnOff($Value)); IPS_SetHidden($ChildrenId, !$Value); } } else { $GroupSwitchId = get_ControlIdByRoomId($RoomId, c_Control_Group); IPS_SetHidden($ChildrenId, !GetValue($GroupSwitchId) or !$Value); } } }
IPS_SetIdent($VarId, $ident); } $Mapping = array_merge($Mapping, $AddOnMapping); } if (array_key_exists('forceDP', $Mapping)) { foreach ($Mapping['forceDP'] as $ident => $VarTyp) { if (@IPS_GetObjectIDByIdent($ident, $HMDevice) === false) { $VarId = IPS_CreateVariable($VarTyp); IPS_SetParent($VarId, $HMDevice); IPS_SetName($VarId, $ident); IPS_SetIdent($VarId, $ident); } HM_RequestStatus($HMDevice, $ident); } } $Childs = IPS_GetChildrenIDs($HMDevice); if (count($Childs) == 0) { echo "Gerät mit der Addresse " . (string) $Channel['Address'] . " hat keine Datenpunkte." . PHP_EOL; echo " Gerät mit Namen '" . utf8_decode((string) $Channel['Name']) . "' wird wieder gelöscht." . PHP_EOL; echo "--------------------------------------------------------------------" . PHP_EOL; IPS_DeleteInstance($HMDevice); continue; } $DeviceHidden = true; foreach ($Childs as $Var) { $Obj = IPS_GetObject($Var); if (array_key_exists($Obj['ObjectIdent'], $Mapping)) { $Name = sprintf($Mapping[$Obj['ObjectIdent']]['Name Raum'], utf8_decode((string) $Channel['Name']), utf8_decode((string) $Channel->Room[0]['Name'])); // $Name = $NameMappingRoom[$Obj['ObjectIdent']]; IPS_SetName($Var, $Name); // Profil ändern, wenn nicht leer im Mapping
function get_RoomId($RoomName) { $RoomIds = IPS_GetChildrenIDs(c_ID_Roomes); foreach ($RoomIds as $RoomId) { if (IPS_GetName($RoomId)==$RoomName) { return $RoomId; } } return false; }
/** * Liest alle zu Überwachenden Variablen ein. * * @access private */ private function GetAllTargets() { $Links = IPS_GetChildrenIDs($this->InstanceID); foreach ($this->NoTriggerVarList->Items as $IPSVar) { $this->UnregisterVariableWatch($IPSVar->VarId); $this->UnregisterLinkWatch($IPSVar->LinkId); } $TriggerVarList = new TNoTriggerVarList(); foreach ($Links as $Link) { $Objekt = IPS_GetObject($Link); if ($Objekt['ObjectType'] != otLink) { continue; } $Target = @IPS_GetObject(IPS_GetLink($Link)['TargetID']); if ($Target === false) { continue; } if ($Target['ObjectType'] != otVariable) { continue; } // zur Liste hinzufügen und Register auf Variable, Link etc... $NoTriggerVar = new TNoTriggerVar($Target['ObjectID'], $Link, false); $TriggerVarList->Add($NoTriggerVar); } $this->NoTriggerVarList = $TriggerVarList; foreach ($TriggerVarList->Items as $IPSVar) { $this->RegisterVariableWatch($IPSVar->VarId); $this->RegisterLinkWatch($IPSVar->LinkId); } }
private function deviceInstanceExists($name) { //if ($isUpdate) //{ $children = IPS_GetChildrenIDs($this->InstanceID); foreach ($children as $child) { if (IPS_InstanceExists($child)) { $childInstance = @IPS_GetInstance($child); $childInstanceID = $childInstance['InstanceID']; $childInstanceName = @IPS_GetName($childInstanceID); // Check if it is a Dummy Module and if it has a known device name if ($childInstanceName == $name and $childInstance['ModuleInfo']['ModuleID'] == "{485D0419-BE97-4548-AA9C-C083EB82E61E}") { return true; } } } return false; //} else { // return false; //} }
/** * @public * * Liefert eine Liste aller installierten Module * * @return string[] Liste der installierten Module */ public function GetInstalledModules() { $childrenIds = IPS_GetChildrenIDs($this->instanceId); $result = array(); foreach ($childrenIds as $id) { $result[IPS_GetName($id)] = GetValue($id); } return $result; }
private function getDeviceAddress($deviceName) { $ret = IPS_GetInstanceListByModuleID("{44D8BE09-743E-484F-A64D-154C4235BE94}"); $DeviceURL = ""; $AccessToken = ""; $retArray = ""; $SecChannelExp = 0; if ($ret == null) { echo "Error: ips4WinDeviceRegistration is not implemented! Please create a new instance of ips4WinDeviceRegistration!\n"; } else { if (count($ret) > 1) { echo "Error: multiple ips4WinDeviceRegistration found, unsupported installation! Please make sure you have only one instance of ips4WinDeviceRegistration!\n"; } else { $id = $ret[0]; $objList = IPS_GetChildrenIDs($id); //print_r($objList); $i = count($objList); for ($j = 0; $j < $i; $j++) { $vid = @IPS_GetObjectIDByName("deviceName", $objList[$j]); if ($vid !== false) { if ($deviceName == null) { $device = GetValueString($vid); $vid = @IPS_GetObjectIDByName("SecChannel", $objList[$j]); if ($vid !== false) { $DeviceURL = GetValueString($vid); } $vid = @IPS_GetObjectIDByName("AccessToken", $objList[$j]); if ($vid !== false) { $AccessToken = GetValueString($vid); } $vid = @IPS_GetObjectIDByName("SecChannelExp", $objList[$j]); if ($vid !== false) { $SecChannelExp = GetValueInteger($vid); } if ($retArray == "") { $retArray[0] = explode("###", $device . "###" . $DeviceURL . "###" . $AccessToken . "###" . $SecChannelExp); } else { $retArray[count($retArray)] = explode("###", $device . "###" . $DeviceURL . "###" . $AccessToken . "###" . $SecChannelExp); } $DeviceURL = ""; $AccessToken = ""; $SecChannelExp = 0; } else { if (strtolower($deviceName) == strtolower(GetValueString($vid))) { $vid = @IPS_GetObjectIDByName("SecChannel", $objList[$j]); if ($vid !== false) { $DeviceURL = GetValueString($vid); } $vid = @IPS_GetObjectIDByName("AccessToken", $objList[$j]); if ($vid !== false) { $AccessToken = GetValueString($vid); } $vid = @IPS_GetObjectIDByName("SecChannelExp", $objList[$j]); if ($vid !== false) { $SecChannelExp = GetValueInteger($vid); } $retArray = array(explode("###", $deviceName . "###" . $DeviceURL . "###" . $AccessToken . "###" . $SecChannelExp)); $j = $i; } } } } } } return $retArray; }
<? /**@ingroup entertainment * @{ * * @file Entertainment_PostInstallation.ips.php * @author Andreas Brauneis * @version * Version 2.50.1, 31.01.2012<br/> * * Dieses Script wird nach jeder Installation der Entertainment Steuerung ausgeführt und * führt einige kleinere Nacharbeiten aus. */ //Sync Devices to Roomes echo "--- Default Settings -------------------------------------------------------------------\n"; IPSUtils_Include ("Entertainment.inc.php", "IPSLibrary::app::modules::Entertainment"); Entertainment_SyncAllRoomControls(); $RoomIds = IPS_GetChildrenIDs(c_ID_Roomes); foreach ($RoomIds as $RoomId) { $RoomPowerId = get_ControlIdByRoomId($RoomId, c_Control_RoomPower); Entertainment_SetRoomVisible($RoomPowerId, GetValue($RoomPowerId)); } /** @}*/ ?>
private function AddObjects() { $childrenIds = IPS_GetChildrenIDs($this->currentId); foreach ($childrenIds as $idx=>$childrenId) { $object = IPS_GetObject($childrenId); $name = IPS_GetName($childrenId); $position = $object['ObjectPosition']; $linkId = $childrenId; if ($object['ObjectType']==6) { // Link $link = IPS_GetLink($childrenId); $childrenId = $link['LinkChildID']; $object = IPS_GetObject($childrenId); } switch($object['ObjectType']) { case 0: // Category case 1: // Instance echo 'Found Category '.$name."\n"; $this->AddObjectCategory($linkId, $childrenId, $name, $position); break; case 2: // Variable echo 'Found Variable '.$name."\n"; $this->AddObjectVariable($linkId, $childrenId, $name, $position); break; case 3: // Script echo 'Found Script '.$name."\n"; $this->AddObjectScript($linkId, $childrenId, $name, $position); break; default: // Unsupported Object ... } } }
function Entertainment_SyncAllRoomControls() { $RoomIds = IPS_GetChildrenIDs(c_ID_Roomes); foreach ($RoomIds as $RoomId) { Entertainment_SyncRoomControls($RoomId); } }
/** * @public * * Methode um autretende IR Events zu processen * * @param integer $variable ID der auslösenden Variable * @param string $value Wert der Variable */ public function HandleIREvent($variable, $value) { $configuration = IPSMessageHandler_GetEventConfigurationIR(); if ($value == '') { return; } $irButton = $value; $irInstanceId = IPS_GetParent($variable); $childrenIds = IPS_GetChildrenIDs($irInstanceId); foreach ($childrenIds as $id) { if ($id <> $variable) { $irRemoteControl = GetValue($id); } } IPSLogger_Com(__file__, "Received Data from IR-Variable, Control='$irRemoteControl', Command='$irButton'"); $irMessage = $irRemoteControl.','.$irButton; if (array_key_exists($irRemoteControl.'.'.$irButton, $configuration)) { $params = $configuration[$irRemoteControl.'.'.$irButton]; } elseif (array_key_exists($irRemoteControl.'.*', $configuration)) { $params = $configuration[$irRemoteControl.'.'.$irButton]; } else { $params = ''; } if ($params<>'') { if (count($params) < 2) { throw new IPSMessageHandlerException('Invalid IPSMessageHandler Configuration, Event Defintion needs 2 parameters'); } $component = IPSComponent::CreateObjectByParams($params[0]); $module = IPSModule::CreateObjectByParams($params[1]); if (function_exists('IPSMessageHandler_BeforeHandleEvent')) { if (IPSMessageHandler_BeforeHandleEvent($variable, $value, $component, $module)) { $component->HandleEvent($variable, $value, $module); } } else { $component->HandleEvent($variable, $value, $module); } if (function_exists('IPSMessageHandler_AfterHandleEvent')) { IPSMessageHandler_AfterHandleEvent($variable, $value, $component, $module); } } }