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; } }
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); } } }
public function ApplyChanges() { //Never delete this line! parent::ApplyChanges(); $IRCode1 = $this->ReadPropertyString("IRCode1"); $IRCode2 = $this->ReadPropertyString("IRCode2"); $IRLabel1 = $this->ReadPropertyString("IRLabel1"); $IRLabel2 = $this->ReadPropertyString("IRLabel2"); $LearnIRCode = $this->ReadPropertyBoolean('LearnIRCode'); $NumberIRCodes = $this->ReadPropertyString("NumberIRCodes"); //Mögliche Prüfungen durchführen if ($LearnIRCode) { $irid = $this->ReadPropertyInteger("LearnIRCodeID"); $this->Learn($irid); } elseif ($IRCode1 == '' or $IRCode2 == '' or $IRLabel1 == '' or $IRLabel2 == '') { // Status Error Felder dürfen nicht leer sein $this->SetStatus(202); } else { if ($NumberIRCodes == 0) { $ircodes = $this->ArrIRCodes(); //Anzahl an IR Codes for ($i = 0; $i <= 99; $i++) { if (empty($ircodes[$i][1])) { $NumberIRCodes = $i; //Anzahl der IRCodes mit Inhalt beim ersten leeren Feld wird abgebrochen break; } } $this->CreateProfileIR($NumberIRCodes); } else { $this->CreateProfileIR($NumberIRCodes); } // Status aktiv $this->SetStatus(102); } //Variablen bei Bedarf //Add/Remove according to feature activation // create link list for deletion of liks if target is deleted $links = array(); foreach (IPS_GetLinkList() as $key => $LinkID) { $links[] = array('LinkID' => $LinkID, 'TargetID' => IPS_GetLink($LinkID)['TargetID']); } // Statusanzeige if ($this->ReadPropertyBoolean("IRStatus")) { $stateIR = $this->RegisterVariableBoolean("Status", "Status", "~Switch", 1); $this->EnableAction("Status"); } else { $this->removeVariableAction("Status", $links); } }
/** * 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); } }
public function ApplyChanges() { $ipAddress = $this->ReadPropertyString("IPAddress"); if ($ipAddress) { $curl = curl_init(); curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://' . $ipAddress . ':1400/xml/device_description.xml')); $result = curl_exec($curl); if (!curl_exec($curl)) { die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl)); } } //Never delete this line! parent::ApplyChanges(); // Start create profiles $this->RegisterProfileIntegerEx("Status.SONOS", "Information", "", "", array(array(0, "Prev", "", -1), array(1, "Play", "", -1), array(2, "Pause", "", -1), array(3, "Stop", "", -1), array(4, "Next", "", -1), array(5, "Transition", "", -1))); $this->RegisterProfileInteger("Volume.SONOS", "Intensity", "", " %", 0, 100, 1); $this->RegisterProfileInteger("Tone.SONOS", "Intensity", "", " %", -10, 10, 1); $this->RegisterProfileInteger("Balance.SONOS", "Intensity", "", " %", -100, 100, 1); $this->RegisterProfileIntegerEx("Switch.SONOS", "Information", "", "", array(array(0, "Off", "", 0xff0000), array(1, "On", "", 0xff00))); //Build Radio Station Associations according to user settings if (!IPS_VariableProfileExists("Radio.SONOS")) { $this->UpdateRadioStations(); } // Build Group Associations according Sonos Instance settings $allSonosInstances = IPS_GetInstanceListByModuleID("{F6F3A773-F685-4FD2-805E-83FD99407EE8}"); $GroupAssociations = array(array(0, "none", "", -1)); foreach ($allSonosInstances as $key => $SonosID) { if (@IPS_GetProperty($SonosID, "GroupCoordinator")) { $GroupAssociations[] = array($SonosID, IPS_GetName($SonosID), "", -1); } } if (IPS_VariableProfileExists("Groups.SONOS")) { IPS_DeleteVariableProfile("Groups.SONOS"); } $this->RegisterProfileIntegerEx("Groups.SONOS", "Network", "", "", $GroupAssociations); // End Create Profiles // Start Register variables and Actions // 1) general availabe $this->RegisterVariableString("nowPlaying", "nowPlaying", "", 20); $this->RegisterVariableInteger("Radio", "Radio", "Radio.SONOS", 21); $this->RegisterVariableInteger("Status", "Status", "Status.SONOS", 29); $this->RegisterVariableInteger("Volume", "Volume", "Volume.SONOS", 30); $this->EnableAction("Radio"); $this->EnableAction("Status"); $this->EnableAction("Volume"); // 2) Add/Remove according to feature activation // create link list for deletion of liks if target is deleted $links = array(); foreach (IPS_GetLinkList() as $key => $LinkID) { $links[] = array('LinkID' => $LinkID, 'TargetID' => IPS_GetLink($LinkID)['TargetID']); } // 2a) Bass if ($this->ReadPropertyBoolean("BassControl")) { $this->RegisterVariableInteger("Bass", "Bass", "Tone.SONOS", 36); $this->EnableAction("Bass"); } else { $this->removeVariableAction("Bass", $links); } // 2b) Treble if ($this->ReadPropertyBoolean("TrebleControl")) { $this->RegisterVariableInteger("Treble", "Treble", "Tone.SONOS", 37); $this->EnableAction("Treble"); } else { $this->removeVariableAction("Treble", $links); } // 2c) Mute if ($this->ReadPropertyBoolean("MuteControl")) { $this->RegisterVariableInteger("Mute", "Mute", "Switch.SONOS", 31); $this->EnableAction("Mute"); } else { $this->removeVariableAction("Mute", $links); } // 2d) Loudness if ($this->ReadPropertyBoolean("LoudnessControl")) { $this->RegisterVariableInteger("Loudness", "Loudness", "Switch.SONOS", 35); $this->EnableAction("Loudness"); } else { $this->removeVariableAction("Loudness", $links); } // 2e) Balance if ($this->ReadPropertyBoolean("BalanceControl")) { $this->RegisterVariableInteger("Balance", "Balance", "Balance.SONOS", 38); $this->EnableAction("Balance"); } else { $this->removeVariableAction("Balance", $links); } // 2f Sleeptimer if ($this->ReadPropertyBoolean("SleeptimerControl")) { $this->RegisterVariableInteger("Sleeptimer", "Sleeptimer", "", 39); } else { $this->removeVariable("Sleeptimer", $links); } // 2g Playlists if ($this->ReadPropertyBoolean("PlaylistControl")) { if (!IPS_VariableProfileExists("Playlist.SONOS")) { $this->RegisterProfileIntegerEx("Playlist.SONOS", "Database", "", "", array()); } $this->RegisterVariableInteger("Playlist", "Playlist", "Playlist.SONOS", 22); $this->EnableAction("Playlist"); } else { $this->removeVariable("Playlist", $links); } // 2h) GroupVolume, GroupMembers, MemberOfGroup if ($this->ReadPropertyBoolean("GroupCoordinator")) { IPS_SetHidden($this->RegisterVariableString("GroupMembers", "GroupMembers", "", 10), true); $this->RegisterVariableInteger("GroupVolume", "GroupVolume", "Volume.SONOS", 11); $this->EnableAction("GroupVolume"); $this->removeVariableAction("MemberOfGroup", $links); } else { $this->RegisterVariableInteger("MemberOfGroup", "MemberOfGroup", "Groups.SONOS", 12); $this->EnableAction("MemberOfGroup"); $this->removeVariableAction("GroupVolume", $links); $this->removeVariable("GroupMembers", $links); } // 2i) Hide/unhide MemberOfGroup depending on presence of GroupCoordinators if (sizeof($GroupAssociations) === 1) { // hide MemberOfGroup foreach ($allSonosInstances as $key => $SonosID) { $GroupingID = @IPS_GetVariableIDByName("MemberOfGroup", $SonosID); if ($GroupingID) { IPS_SetHidden($GroupingID, true); } } } else { // unhide MemberOfGroup foreach ($allSonosInstances as $key => $SonosID) { $GroupingID = @IPS_GetVariableIDByName("MemberOfGroup", $SonosID); if ($GroupingID) { IPS_SetHidden($GroupingID, false); } } } // End Register variables and Actions // Start add scripts for regular status and grouping updates // 1) _updateStatus $statusScriptID = @$this->GetIDForIdent("_updateStatus"); if ($statusScriptID === false) { $statusScriptID = $this->RegisterScript("_updateStatus", "_updateStatus", file_get_contents(__DIR__ . "/_updateStatus.php"), 98); } else { IPS_SetScriptContent($statusScriptID, file_get_contents(__DIR__ . "/_updateStatus.php")); } IPS_SetHidden($statusScriptID, true); IPS_SetScriptTimer($statusScriptID, 5); // 2) _updateGrouping $groupingScriptID = @$this->GetIDForIdent("_updateGrouping"); if ($groupingScriptID === false) { $groupingScriptID = $this->RegisterScript("_updateGrouping", "_updateGrouping", file_get_contents(__DIR__ . "/_updateGrouping.php"), 99); } else { IPS_SetScriptContent($groupingScriptID, file_get_contents(__DIR__ . "/_updateGrouping.php")); } IPS_SetHidden($groupingScriptID, true); IPS_SetScriptTimer($groupingScriptID, 300); // End add scripts for regular status and grouping updates }
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 ... } } }