public function Update() { //Anzahl IPS Events ermitteln $this->SetValueInteger("IPSEvents", count(IPS_GetEventList())); //Anzahl IPS Instanzen ermitteln $this->SetValueInteger("IPSInstanzen", count(IPS_GetInstanceList())); //Anzahl IPS Kategorien ermitteln $this->SetValueInteger("IPSKategorien", count(IPS_GetCategoryList())); //Anzahl IPS Links ermitteln $this->SetValueInteger("IPSLinks", count(IPS_GetLinkList())); //Anzahl IPS Module ermitteln $this->SetValueInteger("IPSModule", count(IPS_GetModuleList())); //Anzahl IPS Objekte ermitteln $this->SetValueInteger("IPSObjekte", count(IPS_GetObjectList())); //Anzahl IPS Profile ermitteln $this->SetValueInteger("IPSProfile", count(IPS_GetVariableProfileList())); //Anzahl IPS Skripte ermitteln $this->SetValueInteger("IPSSkripte", count(IPS_GetScriptList())); //Anzahl IPS Variablen ermitteln $this->SetValueInteger("IPSVariablen", count(IPS_GetVariableList())); //Anzahl IPS Variablen ermitteln $this->SetValueInteger("IPSMedien", count(IPS_GetMediaList())); //Anzahl IPS Librarys ermitteln $this->SetValueInteger("IPSLibrarys", count(IPS_GetLibraryList())); // Groesse des Script-Verzeichnis $this->SetValueFloat("IPSScriptDirSize", $this->GetDirSize(IPS_GetKernelDir() . "scripts")); // Groesse des Log-Verzeichnis $this->SetValueFloat("IPSLogDirSize", $this->GetDirSize(IPS_GetLogDir())); // Groesse des Datenbank-Verzeichnis $this->SetValueFloat("IPSDBSize", $this->GetDirSize(IPS_GetKernelDir() . "db")); //Letzter IPS-Start $this->SetValueInteger("IPSStartTime", IPS_GetUptime()); }
public function Update() { //Anzahl IPS Events ermitteln $this->SetValueInteger("IPSEvents", count(IPS_GetEventList())); //Anzahl IPS Instanzen ermitteln $this->SetValueInteger("IPSInstanzen", count(IPS_GetInstanceList())); //Anzahl IPS Kategorien ermitteln $this->SetValueInteger("IPSKategorien", count(IPS_GetCategoryList())); //Anzahl IPS Links ermitteln $this->SetValueInteger("IPSLinks", count(IPS_GetLinkList())); //Anzahl IPS Module ermitteln $this->SetValueInteger("IPSModule", count(IPS_GetModuleList())); //Anzahl IPS Objekte ermitteln $this->SetValueInteger("IPSObjekte", count(IPS_GetObjectList())); //Anzahl IPS Profile ermitteln $this->SetValueInteger("IPSProfile", count(IPS_GetVariableProfileList())); //Anzahl IPS Skripte ermitteln $this->SetValueInteger("IPSSkripte", count(IPS_GetScriptList())); //Anzahl IPS Variablen ermitteln $this->SetValueInteger("IPSVariablen", count(IPS_GetVariableList())); //Anzahl IPS Variablen ermitteln $this->SetValueInteger("IPSMedien", count(IPS_GetMediaList())); //Anzahl IPS Librarys ermitteln $this->SetValueInteger("IPSLibrarys", count(IPS_GetLibraryList())); // Groesse des Script-Verzeichnis $this->SetValueInteger("IPSScriptDirSize", $this->GetDirSize(IPS_GetKernelDir() . "scripts")); // Groesse des Log-Verzeichnis $this->SetValueInteger("IPSLogDirSize", $this->GetDirSize(IPS_GetLogDir())); // Groesse des Datenbank-Verzeichnis $this->SetValueInteger("IPSDBSize", $this->GetDirSize(IPS_GetKernelDir() . "db")); //Letzter IPS-Start $this->SetValueInteger("IPSStartTime", IPS_GetKernelStartTime()); //Subscription Ablaufdatum $Benutzername = $this->ReadPropertyString("IPSForumBenutzer"); $Passwort = $this->ReadPropertyString("IPSForumPasswort"); if (strlen($Benutzername) > 0 and strlen($Passwort) > 0) { $page = $this->vBulletinLoginIPS($Benutzername, $Passwort); preg_match('|Subskription bis:.(.*)\\W|', $page, $SubscriptionMatch); if ($SubscriptionMatch) { $SubscriptionAblaufdatumX = $SubscriptionMatch[1]; $SubscriptionAblaufdatum = trim(strip_tags($SubscriptionAblaufdatumX)); $SubscriptionAblaufdatum = date_create_from_format('d.m.y', $SubscriptionAblaufdatum); $SubscriptionAblaufdatumUnix = strtotime($SubscriptionAblaufdatum->format('d.m.Y')); $this->SetValueInteger("SubscriptionAblaufVAR", $SubscriptionAblaufdatumUnix); } preg_match('|Version:.(.*).#(.*)|', $page, $VersionMatch); if ($VersionMatch) { $VersionMatchV = $VersionMatch[1]; $VersionMatchB = $VersionMatch[2]; $VersionMatchV = trim(strip_tags($VersionMatchV)); $VersionMatchB = trim(strip_tags($VersionMatchB)); $VersionALL = $VersionMatchV . " #" . $VersionMatchB; $this->SetValueString("IPSVersion", $VersionALL); $this->SetValueFloat("IPSVersionMain", (double) $VersionMatchV); $this->SetValueInteger("IPSVersionBuild", (int) $VersionMatchB); } } }
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); } }
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 }