protected function RegisterProfile($Name, $VariablenTyp, $Icon, $Prefix, $Suffix, $MinValue, $MaxValue, $StepSize) { if (!IPS_VariableProfileExists($Name)) { IPS_CreateVariableProfile($Name, $VariablenTyp); } else { $profile = IPS_GetVariableProfile($Name); if ($profile['ProfileType'] != $VariablenTyp) { throw new Exception("Variable profile type does not match for profile " . $Name); } } IPS_SetVariableProfileIcon($Name, $Icon); IPS_SetVariableProfileText($Name, $Prefix, $Suffix); IPS_SetVariableProfileValues($Name, $MinValue, $MaxValue, $StepSize); }
public function Create() { parent::Create(); $this->RegisterPropertyString("Host", ""); $this->RegisterPropertyString("Zone", "Main_Zone"); $this->RegisterPropertyInteger("UpdateInterval", 5); if (!IPS_VariableProfileExists('Volume.YAVR')) { IPS_CreateVariableProfile('Volume.YAVR', 2); } IPS_SetVariableProfileDigits('Volume.YAVR', 1); IPS_SetVariableProfileIcon('Volume.YAVR', 'Intensity'); IPS_SetVariableProfileText('Volume.YAVR', "", " dB"); IPS_SetVariableProfileValues('Volume.YAVR', -80, 16, 0.5); $this->UpdateScenesProfile(); $this->UpdateInputsProfile(); }
public function ApplyChanges() { // Diese Zeile nicht löschen parent::ApplyChanges(); //Variablenprofil anlegen if (!IPS_VariableProfileExists("Megabyte")) { IPS_CreateVariableProfile("Megabyte", 2); IPS_SetVariableProfileValues("Megabyte", 0, 0, 2); IPS_SetVariableProfileText("Megabyte", "", " MB"); } if ($this->ReadPropertyString("IPS_Pfad") != "" and $this->ReadPropertyString("Netzwerkkarte") != "") { //Variablen erstellen $this->RegisterVariableFloat("CPU_idle", "CPU-Auslastung", "Humidity.F", 1); $this->RegisterVariableFloat("CPU_volts", "CPU-Spannung", "Volt", 2); $this->RegisterVariableFloat("CPU_temp", "CPU-Temperatur", "Temperature", 3); $this->RegisterVariableFloat("HDD_total", "Gesamt Speicherplatz", "Megabyte", 4); $this->RegisterVariableFloat("HDD_used", "Belegter Speicherplatz", "Megabyte", 5); $this->RegisterVariableFloat("HDD_percent", "HDD-Belegung", "Humidity.F", 6); $this->RegisterVariableFloat("HDD_symcon", "IPS-Speicherbelegung", "Megabyte", 7); $this->RegisterVariableFloat("RAM_total", "Gesamt RAM", "Megabyte", 8); $this->RegisterVariableFloat("RAM_used", "Benutzer RAM", "Megabyte", 9); $this->RegisterVariableFloat("RAM_percent", "RAM-Auslastung", "Humidity.F", 10); $this->RegisterVariableString("System_Info", "System Informationen", "HTMLBox", 11); //Timer zeit setzen $this->SetTimerInterval("Update", $this->ReadPropertyInteger("UpdateInterval") * 1000); } else { //Instanz ist inaktiv $this->SetStatus(104); } //Variablen Logging Aktivieren / Deaktivieren $archiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0]; AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_idle"), $this->ReadPropertyBoolean("logCPU_idle")); AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_volts"), $this->ReadPropertyBoolean("logCPU_volts")); AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_temp"), $this->ReadPropertyBoolean("logCPU_temp")); AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_total"), $this->ReadPropertyBoolean("logHDD_total")); AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_used"), $this->ReadPropertyBoolean("logHDD_used")); AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_percent"), $this->ReadPropertyBoolean("logHDD_percent")); AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_symcon"), $this->ReadPropertyBoolean("logHDD_symcon")); AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_total"), $this->ReadPropertyBoolean("logRAM_total")); AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_used"), $this->ReadPropertyBoolean("logRAM_used")); AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_percent"), $this->ReadPropertyBoolean("logRAM_percent")); IPS_ApplyChanges($archiveHandlerID); copy(IPS_GetKernelDir() . "modules/IPS_PI_Monitor/PI_Monitor/Raspi-PGB001.png", IPS_GetKernelDir() . "webfront/user/Raspi-PGB001.png"); }
public function Create() { // Diese Zeile nicht löschen. parent::Create(); $this->RegisterPropertyString("API", ""); $this->RegisterPropertyString("Location", "Menden"); $this->RegisterPropertyInteger("UpdateInterval", 300); //Variablenprofil anlegen //$this->RegisterProfileFloat("WindSpeed.Kph", "WindSpeed", "", " kn", 0, 100, 1); //$this->RegisterProfileInteger("Distance.km", "Distance", "", " km", 0, 150, 1); if (!IPS_VariableProfileExists("WindSpeed.kt")) { IPS_CreateVariableProfile("WindSpeed.kt", 2); // 2 = Float IPS_SetVariableProfileIcon("WindSpeed.kt", "WindSpeed"); IPS_SetVariableProfileValues("WindSpeed.kt", 0, 100, 1); IPS_SetVariableProfileText("WindSpeed.kt", "", " kn"); } if (!IPS_VariableProfileExists("Distance.km")) { IPS_CreateVariableProfile("Distance.km", 1); // 1 = Integer IPS_SetVariableProfileIcon("Distance.km", "Distance"); IPS_SetVariableProfileValues("Distance.km", 0, 999, 1); IPS_SetVariableProfileText("Distance.km", "", " km"); } //Eigenschaften festlegen $this->RegisterVariableString("Condition", "Wetterbedingung"); $this->RegisterVariableString("WindDirectionString", "Windrichtung"); $this->RegisterVariableInteger("AirPressure", "Luftdruck", "AirPressure"); $this->RegisterVariableInteger("Visibility", "Sichtweite", "Distance.km"); $this->RegisterVariableInteger("Humidity", "Luftfeuchtigkeit", "Humidity"); $this->RegisterVariableInteger("WindDirection", "Windrichtung", "WindDirection"); $this->RegisterVariableFloat("Temperature", "Temperatur", "Temperature"); $this->RegisterVariableFloat("Windchill", "Windchill", "Temperature"); $this->RegisterVariableFloat("Dewpoint", "Taupunkt", "Temperature"); $this->RegisterVariableFloat("WindSpeed", "Wind", "WindSpeed.kt"); $this->RegisterVariableFloat("WindSpeedGust", "Wind in Böen", "WindSpeed.kt"); $this->RegisterVariableFloat("UV", "UV Index"); }
IPS_SetVariableProfileAssociation('ControlMode.HM', 3, 'Boost', '', 0xffff99); } if (!IPS_VariableProfileExists('DimmerControl.HM')) { IPS_CreateVariableProfile('DimmerControl.HM', 1); IPS_SetVariableProfileIcon('DimmerControl.HM', 'Intensity'); IPS_SetVariableProfileAssociation('DimmerControl.HM', -2, '0 %', '', 0xff); IPS_SetVariableProfileAssociation('DimmerControl.HM', -1, 'Dunkler', '', 0x339966); IPS_SetVariableProfileAssociation('DimmerControl.HM', 0, 'Stop', '', 0x0); IPS_SetVariableProfileAssociation('DimmerControl.HM', 1, 'Zurück', '', 0xff0000); IPS_SetVariableProfileAssociation('DimmerControl.HM', 2, 'Heller', '', 0x339966); IPS_SetVariableProfileAssociation('DimmerControl.HM', 3, '100 %', '', 0xff); } if (!IPS_VariableProfileExists('DimmerSpeed.HM')) { IPS_CreateVariableProfile('DimmerSpeed.HM', 2); IPS_SetVariableProfileIcon('DimmerSpeed.HM', 'Intensity'); IPS_SetVariableProfileValues('DimmerSpeed.HM', 0, 30, 2); IPS_SetVariableProfileText('DimmerSpeed.HM', '', ' s'); } # ENDE Konfig $AddOnMappings = array('BLIND' => array('CONTROL' => array('Name Raum' => 'Steuerung', 'Name Gewerk' => 'Steuerung %2$s', 'Profil' => 'BlindControl.HM', 'Action' => 'BLIND_SCRIPT', 'VarTyp' => 1)), 'THERMALCONTROL_TRANSMIT' => array('CONTROL_TEMP' => array('Name Raum' => 'Soll Temperatur Vorwahl', 'Name Gewerk' => 'Soll Temperatur Vorwahl %2$s', 'Profil' => 'ControlTemp.HM', 'Action' => 'CONTROL_TEMP_SCRIPT', 'VarTyp' => 1)), 'CLIMATECONTROL_RT_TRANSCEIVER' => array('CONTROL_TEMP' => array('Name Raum' => 'Soll Temperatur Vorwahl', 'Name Gewerk' => 'Soll Temperatur Vorwahl %2$s', 'Profil' => 'ControlTemp.HM', 'Action' => 'CONTROL_TEMP_SCRIPT', 'VarTyp' => 1)), 'DIMMER' => array('DIMMER_CONTROL' => array('Name Raum' => 'Steuerung', 'Name Gewerk' => 'Steuerung %2$s', 'Profil' => 'DimmerControl.HM', 'Action' => 'DIMMER_SCRIPT', 'VarTyp' => 1), 'RAMP_TIME' => array('Name Raum' => 'Geschwindigkeit', 'Name Gewerk' => 'Geschwindigkeit %2$s', 'Profil' => 'DimmerSpeed.HM', 'Action' => 'DIMMER_SCRIPT', 'VarTyp' => 2)), 'VIRTUAL_DIMMER' => array('DIMMER_CONTROL' => array('Name Raum' => 'Steuerung', 'Name Gewerk' => 'Steuerung %2$s', 'Profil' => 'DimmerControl.HM', 'Action' => 'DIMMER_SCRIPT', 'VarTyp' => 1), 'RAMP_TIME' => array('Name Raum' => 'Geschwindigkeit', 'Name Gewerk' => 'Geschwindigkeit %2$s', 'Profil' => 'DimmerSpeed.HM', 'Action' => 'DIMMER_SCRIPT', 'VarTyp' => 2))); ini_set('max_execution_time', count($HMCcuAddress) * 120); //HM Sockets prüfen und einrichten $nextPort = 5544; $HMSockets = array_flip($HMCcuAddress); $HMSocketsOld = IPS_GetInstanceListByModuleID("{A151ECE9-D733-4FB9-AA15-7F7DD10C58AF}"); if (count($HMSocketsOld) > 0) { foreach ($HMSocketsOld as $HMSocket) { $HMSocketIDsOld[IPS_GetProperty($HMSocket, 'Host')] = $HMSocket; $Port = IPS_GetProperty($HMSocket, 'Port'); if ($Port >= $nextPort) { $nextPort = $Port + 1;
protected function RegisterProfileIntegerEx($Name, $Icon, $Prefix, $Suffix, $Associations) { if (sizeof($Associations) === 0) { $MinValue = 0; $MaxValue = 0; } else { $MinValue = $Associations[0][0]; $MaxValue = $Associations[sizeof($Associations) - 1][0]; } if (!IPS_VariableProfileExists($Name)) { IPS_CreateVariableProfile($Name, 1); } else { $profile = IPS_GetVariableProfile($Name); if ($profile['ProfileType'] != 1) throw new Exception("Variable profile type does not match for profile " . $Name); } IPS_SetVariableProfileIcon($Name, $Icon); IPS_SetVariableProfileText($Name, $Prefix, $Suffix); IPS_SetVariableProfileValues($Name, $MinValue, $MaxValue, 0); foreach ($Associations as $Association) { IPS_SetVariableProfileAssociation($Name, $Association[0], $Association[1], $Association[2], $Association[3]); } }
protected function RegisterProfileLEDGateway($Name, $Icon, $Prefix, $Suffix) { if (!IPS_VariableProfileExists($Name)) { IPS_CreateVariableProfile($Name, 1); } else { $profile = IPS_GetVariableProfile($Name); if ($profile['ProfileType'] != 1) { throw new Exception("Variable profile type does not match for profile " . $Name); } } $MinValue = 0; $MaxValue = 4; $StepSize = 1; IPS_SetVariableProfileIcon($Name, $Icon); IPS_SetVariableProfileText($Name, $Prefix, $Suffix); IPS_SetVariableProfileValues($Name, $MinValue, $MaxValue, $StepSize); // boolean IPS_SetVariableProfileAssociation ( string $ProfilName, float $Wert, string $Name, string $Icon, integer $Farbe ) Farbwert im HTML Farbcode (z.b. 0x0000FF für Blau). Sonderfall: -1 für transparent IPS_SetVariableProfileAssociation($Name, 0, "Weiß", "", 0xfffffff); IPS_SetVariableProfileAssociation($Name, 1, "Blau", "", 0x13adf); IPS_SetVariableProfileAssociation($Name, 2, "Grün", "", 0x88a08); IPS_SetVariableProfileAssociation($Name, 3, "Rot", "", 0xfe2e2e); IPS_SetVariableProfileAssociation($Name, 4, "Aus", "", 0x585858); }
protected function RegisterProfileColor($Name, $Icon, $Prefix, $Suffix) { if (!IPS_VariableProfileExists($Name)) { IPS_CreateVariableProfile($Name, 1); } else { $profile = IPS_GetVariableProfile($Name); if ($profile['ProfileType'] != 1) { throw new Exception("Variable profile type does not match for profile " . $Name); } } $MinValue = 0; $MaxValue = 7; $StepSize = 1; IPS_SetVariableProfileIcon($Name, $Icon); IPS_SetVariableProfileText($Name, $Prefix, $Suffix); IPS_SetVariableProfileValues($Name, $MinValue, $MaxValue, $StepSize); // boolean IPS_SetVariableProfileAssociation ( string $ProfilName, float $Wert, string $Name, string $Icon, integer $Farbe ) Farbwert im HTML Farbcode (z.b. 0x0000FF für Blau). Sonderfall: -1 für transparent IPS_SetVariableProfileAssociation($Name, 0, "Rot", "", 0xfe2e2e); IPS_SetVariableProfileAssociation($Name, 1, "Orange", "", 0xffbf00); IPS_SetVariableProfileAssociation($Name, 2, "Gelb", "", 0xf7fe2e); IPS_SetVariableProfileAssociation($Name, 3, "Grün", "", 0x64fe2e); IPS_SetVariableProfileAssociation($Name, 4, "Cyan", "", 0x81f7f3); IPS_SetVariableProfileAssociation($Name, 5, "Blau", "", 0xff); IPS_SetVariableProfileAssociation($Name, 6, "Lila", "", 0xda81f5); IPS_SetVariableProfileAssociation($Name, 7, "Weiß", "", 0xffffff); }
public function ApplyChanges() { // get instance id $instanceid = IPS_GetInstance($this->InstanceID)['InstanceID']; // rename instance $room = $this->ReadPropertyString("Room"); if ($room != "") { IPS_SetName($instanceid, $room); } // check device $deviceip = $this->ReadPropertyString("DeviceIP"); $timeout = $this->ReadPropertyString("Timeout"); if ($deviceip != "") { // check device availability if ($timeout && Sys_Ping($deviceip, $timeout) != true) { // throw new Exception("Device ".$deviceip." is not available"); die("Unable to connect to device {$deviceip}"); } include_once __DIR__ . "/bose_soundtouch_api.php"; $bosedevice = new BoseSoundTouchAPI($deviceip); $result = $bosedevice->getDeviceNowPlayingAPI(); // get device id for multiroom $deviceid = $this->ReadPropertyString("DeviceID"); if ($deviceid == "" and $deviceip != "") { $deviceid = $result['deviceid']; IPS_SetProperty($instanceid, "DeviceID", "" . $deviceid . ""); if (IPS_HasChanges($instanceid)) { IPS_ApplyChanges($instanceid); } } } // never delete this line! parent::ApplyChanges(); ///////////////////////////////////////////////////////////////////////////////////////////////////////// // create profiles ///////////////////////////////////////////////////////////////////////////////////////////////////////// //create zone profiles for multiroom $allboseinstances = IPS_GetInstanceListByModuleID("{4836EF46-FF79-4D6A-91C9-FE54F1BDF2DB}"); // create profile for each instance / device foreach ($allboseinstances as $key => $instanceid) { $multiroomprofilename = "bose.Device" . $instanceid . "MasterZones"; // delete zone profiles if (IPS_VariableProfileExists($multiroomprofilename)) { IPS_DeleteVariableProfile($multiroomprofilename); } IPS_CreateVariableProfile($multiroomprofilename, 1); // set values for profile foreach ($allboseinstances as $key => $value) { if ($instanceid == $value) { IPS_SetVariableProfileAssociation($multiroomprofilename, "0", "Off", "", 0xff); } else { $instancename = IPS_GetName($value); if ($instancename != "") { IPS_SetVariableProfileAssociation($multiroomprofilename, "" . ($key + 1) . "", "" . $instancename . "", "", 0xff); } } } } // create volume slider profile $volumesliderprofilename = "bose.VolumeSlider"; if (!IPS_VariableProfileExists($volumesliderprofilename)) { IPS_CreateVariableProfile($volumesliderprofilename, 1); } IPS_SetVariableProfileValues($volumesliderprofilename, 0, 100, 1); IPS_SetVariableProfileText($volumesliderprofilename, "", "%"); IPS_SetVariableProfileIcon($volumesliderprofilename, "Speaker"); // play pause preset $playpauseprofilename = "bose.PlayPause"; if (!IPS_VariableProfileExists($playpauseprofilename)) { IPS_CreateVariableProfile($playpauseprofilename, 1); } IPS_SetVariableProfileAssociation($playpauseprofilename, "0", "Pause", "", 0xff); IPS_SetVariableProfileAssociation($playpauseprofilename, "1", "Play", "", 0xff); IPS_SetVariableProfileIcon($playpauseprofilename, "HollowArrowRight"); // create presets and radiolocations profiles $instanceid = IPS_GetInstance($this->InstanceID)['InstanceID']; $radiostationsprofilename = "bose.Device" . $instanceid . "RadioStations"; if (!IPS_VariableProfileExists($radiostationsprofilename)) { IPS_CreateVariableProfile($radiostationsprofilename, 1); } $radiolocationsprofilename = "bose.Device" . $instanceid . "RadioLocations"; if (!IPS_VariableProfileExists($radiolocationsprofilename)) { IPS_CreateVariableProfile($radiolocationsprofilename, 1); } // get device presets if ($deviceip != "") { include_once __DIR__ . "/bose_soundtouch_api.php"; $bosedevice = new BoseSoundTouchAPI($deviceip); $result = $bosedevice->getDevicePresetsAPI(); for ($i = 0; $i < 6; $i++) { $value = $i + 1; $radiostationname = $result->preset[$i]->ContentItem->itemName; $radiostationlocation = $result->preset[$i]->ContentItem["location"]; IPS_SetVariableProfileAssociation($radiostationsprofilename, "" . $value . "", "" . $radiostationname . "", "", 0xff); IPS_SetVariableProfileAssociation($radiolocationsprofilename, "" . $value . "", "" . $radiostationlocation . "", "", 0xff); } IPS_SetVariableProfileIcon($radiostationsprofilename, "Cloud"); } // create timer hour profile $timerhourprofilename = "bose.TimerHour"; if (!IPS_VariableProfileExists($timerhourprofilename)) { IPS_CreateVariableProfile($timerhourprofilename, 1); } $i = 0; for ($i = 0; $i < 24; $i++) { IPS_SetVariableProfileAssociation($timerhourprofilename, $i, $i, "", 0xff); } IPS_SetVariableProfileIcon($timerhourprofilename, "Clock"); // create timer minute profile $timerminuteprofilename = "bose.TimerMinute"; if (!IPS_VariableProfileExists($timerminuteprofilename)) { IPS_CreateVariableProfile($timerminuteprofilename, 1); } $i = 0; for ($i = 0; $i <= 55; $i = $i + 5) { IPS_SetVariableProfileAssociation($timerminuteprofilename, $i, $i, "", 0xff); } IPS_SetVariableProfileIcon($timerminuteprofilename, "Clock"); ///////////////////////////////////////////////////////////////////////////////////////////////////////// // register variables ///////////////////////////////////////////////////////////////////////////////////////////////////////// // device power $this->RegisterVariableBoolean("DevicePower", "Device Power", "~Switch", 1); $this->EnableAction("DevicePower"); SetValue($this->GetIDForIdent("DevicePower"), 0); // volume slider $this->RegisterVariableInteger("VolumeSlider", "Volume", "bose.VolumeSlider", 2); $this->EnableAction("VolumeSlider"); SetValue($this->GetIDForIdent("VolumeSlider"), 10); // play pause $this->RegisterVariableInteger("PlayPause", "Play / Pause", "bose.PlayPause", 3); $this->EnableAction("PlayPause"); SetValue($this->GetIDForIdent("PlayPause"), true); // join zone (multiroom) $instanceid = IPS_GetInstance($this->InstanceID)['InstanceID']; $this->RegisterVariableInteger("JoinZone", "Join Zone (MultiRoom)", "bose.Device" . $instanceid . "MasterZones", 4); $this->EnableAction("JoinZone"); IPS_SetIcon($this->GetIDForIdent("JoinZone"), "Network"); SetValue($this->GetIDForIdent("JoinZone"), 0); // radio $this->RegisterVariableInteger("Radio", "Radio", "bose.Device" . $instanceid . "RadioStations", 5); $this->EnableAction("Radio"); SetValue($this->GetIDForIdent("Radio"), 1); // device mode $this->RegisterVariableString("DeviceMode", "Device Mode", "", 7); IPS_SetIcon($this->GetIDForIdent("DeviceMode"), "Information"); // device state $this->RegisterVariableString("DeviceState", "Device State", "", 8); IPS_SetIcon($this->GetIDForIdent("DeviceState"), "Information"); // now playing $this->RegisterVariableString("NowPlaying", "Now Playing", "", 9); IPS_SetIcon($this->GetIDForIdent("NowPlaying"), "Information"); // description $this->RegisterVariableString("Description", "Description", "", 10); IPS_SetIcon($this->GetIDForIdent("Description"), "Information"); // logo $this->RegisterVariableString("Logo", "Logo", "~HTMLBox", 11); IPS_SetIcon($this->GetIDForIdent("Logo"), "Information"); // timer hour $this->RegisterVariableInteger("TimerHour", "Timer Hour", "bose.TimerHour", 12); $this->EnableAction("TimerHour"); SetValue($this->GetIDForIdent("TimerHour"), 12); // timer minute $this->RegisterVariableInteger("TimerMinute", "Timer Minute", "bose.TimerMinute", 13); $this->EnableAction("TimerMinute"); SetValue($this->GetIDForIdent("TimerMinute"), 0); // alarm clock $this->RegisterVariableBoolean("AlarmClock", "Alarm Clock", "~Switch", 14); $this->EnableAction("AlarmClock"); SetValue($this->GetIDForIdent("AlarmClock"), false); // volume fade in $this->RegisterVariableBoolean("VolumeFadeIn", "Volume Fade In (15 min)", "~Switch", 15); $this->EnableAction("VolumeFadeIn"); SetValue($this->GetIDForIdent("VolumeFadeIn"), false); // next power on $this->RegisterVariableString("NextPowerOn", "Next Power On", "", 16); IPS_SetIcon($this->GetIDForIdent("NextPowerOn"), "Information"); // alarm cycle IPS_SetHidden($this->RegisterVariableString("AlarmCycle", "Alarm Cycle", "", 17), true); SetValue($this->GetIDForIdent("AlarmCycle"), 0); // alarm radio station IPS_SetHidden($this->RegisterVariableString("AlarmRadioStation", "Alarm Radio Station", "", 18), true); SetValue($this->GetIDForIdent("VolumeFadeIn"), false); // alarm clock volume IPS_SetHidden($this->RegisterVariableInteger("AlarmClockVolume", "Alarm Clock Volume", "bose.VolumeSlider", 19), true); SetValue($this->GetIDForIdent("AlarmRadioStation"), ""); // sleep timer $this->RegisterVariableBoolean("SleepTimer", "Sleep Timer", "~Switch", 20); $this->EnableAction("SleepTimer"); SetValue($this->GetIDForIdent("SleepTimer"), false); // volume fade out $this->RegisterVariableBoolean("VolumeFadeOut", "Volume Fade Out (15 min)", "~Switch", 21); $this->EnableAction("VolumeFadeOut"); SetValue($this->GetIDForIdent("VolumeFadeOut"), false); // good night $this->RegisterVariableBoolean("GoodNight", "Good Night (30 min)", "~Switch", 22); IPS_SetIcon($this->GetIDForIdent("GoodNight"), "Moon"); $this->EnableAction("GoodNight"); SetValue($this->GetIDForIdent("GoodNight"), false); // next power off $this->RegisterVariableString("NextPowerOff", "Next Power Off", "", 23); IPS_SetIcon($this->GetIDForIdent("NextPowerOff"), "Information"); SetValue($this->GetIDForIdent("NextPowerOff"), ""); // sleep cycle IPS_SetHidden($this->RegisterVariableString("SleepCycle", "Sleep Cycle", "", 24), true); SetValue($this->GetIDForIdent("SleepCycle"), 0); ///////////////////////////////////////////////////////////////////////////////////////////////////////// // create scripts ///////////////////////////////////////////////////////////////////////////////////////////////////////// // device information script $DeviceInformationControlScript = '<? /* SymconBoseSoundTouch Bose SoundTouch Module for IP-Symcon filename: DeviceInformationControl.php description: Device Information Control Script version 1.0.1 date: 13.01.2016 publisher: Copyright (c) 2015, 2016 Ulrich Bittner license: CC BY-NC 4.0 Creative Commons Attribution-NonCommercial 4.0 International License environment: IP-Symcon 4.0 (beta) on RPi changelog: version 1.0.1 13.01.2016 multiroom fix for single device version 1.0.0 28.12.2015 initialscript todo: (none) github: https://github.com/ubittner/SymconBoseSoundTouch.git symcon forum: https://www.symcon.de/forum/threads/29922-Bose-SoundTouch-Modul */ if ($_IPS["SENDER"] == "Execute") { addRadioStations(); } if ($_IPS["SENDER"] == "TimerEvent") { getDeviceInformation(); } function addRadioStations() { // Radio Stations // if you want less radio stations, delete the unnecessary positions // if you want to have more radio stations, add positions // get the radio station location id from www.vtuner.com // http://vtuner.com/setupapp/guide/asp/BrowseStations/startpage.asp // example for WDR 2 Ruhrgebiet // url: http://www.vtuner.com/vtunerweb/mms/m3u32760.m3u // location = 32760 // Radio Station 7 $RadioStations["station7"]["name"] = "AH.FM"; $RadioStations["station7"]["location"] = "24836"; // Radio Station 8 $RadioStations["station8"]["name"] = "Sunshine Live Classics"; $RadioStations["station8"]["location"] = "44882"; // Radio Station 9 $RadioStations["station9"]["name"] = "Sunshine Live Trance"; $RadioStations["station9"]["location"] = "48651"; // Radio Station 10 $RadioStations["station10"]["name"] = "Sunshine Live Be Easy"; $RadioStations["station10"]["location"] = "44879"; // Radio Station 11 $RadioStations["station11"]["name"] = "Sunshine Live Be DJ"; $RadioStations["station11"]["location"] = "44881"; // Radio Station 12 $RadioStations["station12"]["name"] = "Sunshine Live Radioclub"; $RadioStations["station12"]["location"] = "62373"; // Radio Station 13 $RadioStations["station13"]["name"] = "SPORT1.fm"; $RadioStations["station13"]["location"] = "52773"; // Radio Station 14 $RadioStations["station14"]["name"] = "SPORT1.fm Spiel1"; $RadioStations["station14"]["location"] = "53341"; // Radio Station 15 $RadioStations["station15"]["name"] = "SPORT1.fm Spiel2"; $RadioStations["station15"]["location"] = "53343"; // Radio Station 16 $RadioStations["station16"]["name"] = "SPORT1.fm Spiel3"; $RadioStations["station16"]["location"] = "53344"; // Radio Station 17 $RadioStations["station17"]["name"] = "SPORT1.fm Spiel4"; $RadioStations["station17"]["location"] = "53346"; // Radio Station 18 $RadioStations["station18"]["name"] = "SPORT1.fm Spiel5"; $RadioStations["station18"]["location"] = "53347"; // Radio Station 19 $RadioStations["station19"]["name"] = "SPORT1.fm Spiel6"; $RadioStations["station19"]["location"] = "53349"; // Radio Station 20 $RadioStations["station20"]["name"] = "WDR2 Ruhrgebiet"; $RadioStations["station20"]["location"] = "32760"; // Radio Station 21 $RadioStations["station21"]["name"] = "BFBS Germany"; $RadioStations["station21"]["location"] = "35142"; // extend radio station and radio location profile $instanceid = IPS_GetParent($_IPS["SELF"]); $presetprofilename = "bose.Device".$instanceid."RadioStations"; $radiolocationsprofilename = "bose.Device".$instanceid."RadioLocations"; $variable = $RadioStations; $i = 7; foreach ($variable as $key => $value) { $radiostationname = $value["name"]; $radiostationlocation = $value["location"]; IPS_SetVariableProfileAssociation($presetprofilename, "".$i."", "".$radiostationname."", "", 0x0000FF); IPS_SetVariableProfileAssociation($radiolocationsprofilename, "".$i."", "".$radiostationlocation."", "", 0x0000FF); $i++; } } function getDeviceInformation() { $deviceip = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "DeviceIP"); $timeout = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "Timeout"); $instanceid = IPS_GetParent($_IPS["SELF"]); if ($deviceip == "") { die; } try { // check device availibility if ($timeout && Sys_Ping($deviceip, $timeout) != true) { throw new Exception("Device ".$deviceip." is not available"); } include_once("../modules/SymconBoseSoundTouch/Bose/bose_soundtouch_api.php"); $bosedevice = new BoseSoundTouchAPI($deviceip); $result = $bosedevice->getDeviceNowPlayingAPI(); // power switch if ($result["devicemode"] == "Standby") { $powerstate = false; } else { $powerstate = true; } $powerswitch = GetValue(IPS_GetObjectIDByName("Device Power", IPS_GetParent($_IPS["SELF"]))); if ($powerstate <> $powerswitch) { SetValue(IPS_GetObjectIDByName("Device Power", IPS_GetParent($_IPS["SELF"])), $powerstate); } // device mode $devicemode = GetValue(IPS_GetObjectIDByName("Device Mode", IPS_GetParent($_IPS["SELF"]))); if ($result["devicemode"] <> $devicemode) { SetValue(IPS_GetObjectIDByName("Device Mode", IPS_GetParent($_IPS["SELF"])), $result["devicemode"]); } // device state $devicestate = GetValue(IPS_GetObjectIDByName("Device State", IPS_GetParent($_IPS["SELF"]))); if ($result["devicestate"] <> $devicestate) { SetValue(IPS_GetObjectIDByName("Device State", IPS_GetParent($_IPS["SELF"])), $result["devicestate"]); } // now playing $nowplaying = GetValue(IPS_GetObjectIDByName("Now Playing", IPS_GetParent($_IPS["SELF"]))); if ($result["nowplaying"] <> $nowplaying) { SetValue(IPS_GetObjectIDByName("Now Playing", IPS_GetParent($_IPS["SELF"])), $result["nowplaying"]); $instanceid = IPS_GetParent($_IPS["SELF"]); $associations = IPS_GetVariableProfile("bose.Device".$instanceid."RadioStations")["Associations"]; $index = 0; foreach($associations as $key => $value) { if ($value["Name"] == $result["nowplaying"]) { $index = $value["Value"]; } } if ($index <> 0){ SetValue(IPS_GetObjectIDByName("Radio", IPS_GetParent($_IPS["SELF"])), $index); } } // description $description = GetValue(IPS_GetObjectIDByName("Description", IPS_GetParent($_IPS["SELF"]))); if ($result["description"] <> $description) { SetValue(IPS_GetObjectIDByName("Description", IPS_GetParent($_IPS["SELF"])), $result["description"]); } // logo $logo = GetValue(IPS_GetObjectIDByName("Logo", IPS_GetParent($_IPS["SELF"]))); if ($result["logourl"] <> $logo) { SetValue(IPS_GetObjectIDByName("Logo", IPS_GetParent($_IPS["SELF"])), $result["logourl"]); } // volume $result = $bosedevice->getDeviceVolumeAPI(); $volumeslider = GetValue(IPS_GetObjectIDByName("Volume", IPS_GetParent($_IPS["SELF"]))); if ($result["actualvolume"] <> $volumeslider) { SetValue(IPS_GetObjectIDByName("Volume", IPS_GetParent($_IPS["SELF"])), $result["actualvolume"]); } // zone $allboseinstances = IPS_GetInstanceListByModuleID("{4836EF46-FF79-4D6A-91C9-FE54F1BDF2DB}"); $numberofdevices = count($allboseinstances); if ($numberofdevices >1) { $result = $bosedevice->getDeviceZoneAPI(); $zonemasterid = $result["zonemasterid"]; $zonememberid = $result["zonememberid"]; $deviceid = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "DeviceID"); $zonemembers = $result["zonememberid"]; $zonemember = false; $masterzone = 0; foreach ($zonemembers as $key => $value) { // device is member if ($value == $deviceid) { // device is the master if ($zonemasterid == $deviceid) { $masterzone = 0; } // get zone master else { $allboseinstances = IPS_GetInstanceListByModuleID("{4836EF46-FF79-4D6A-91C9-FE54F1BDF2DB}"); foreach ($allboseinstances as $key => $value) { $masterdeviceid = IPS_GetProperty($value, "DeviceID"); if ($masterdeviceid == $zonemasterid) { $zonemastername = IPS_GetName($value); } } $associations = IPS_GetVariableProfile("bose.Device".$instanceid."MasterZones")["Associations"]; foreach($associations as $key => $value) { if ($value["Name"] == $zonemastername) { $masterzone = $value["Value"]; } } } } } $zonestate = GetValue(IPS_GetObjectIDByName("Join Zone (MultiRoom)", IPS_GetParent($_IPS["SELF"]))); if ($masterzone <> $zonestate) { SetValue(IPS_GetObjectIDByName("Join Zone (MultiRoom)", IPS_GetParent($_IPS["SELF"])), $masterzone); } } } // error message catch (Exception $e) { echo $e->getMessage(); } } ?>'; // create script $deviceinformationcontrolscriptid = @$this->GetIDForIdent("DeviceInformationControl"); if ($deviceinformationcontrolscriptid === false) { $deviceinformationcontrolscriptid = $this->RegisterScript("DeviceInformationControl", "DeviceInformationControl", $DeviceInformationControlScript, 0); } else { IPS_SetScriptContent($deviceinformationcontrolscriptid, $DeviceInformationControlScript); } IPS_SetHidden($deviceinformationcontrolscriptid, true); IPS_SetScriptTimer($deviceinformationcontrolscriptid, 5); // alarm clock script $AlarmClockControlScript = '<? /* SymconBoseSoundTouch Bose SoundTouch Module for IP-Symcon filename: AlarmClockControl.php description: Alarm Clock Control Script version 1.0.0 date: 28.12.2015 publisher: Copyright (c) 2015, 2016 Ulrich Bittner license: CC BY-NC 4.0 Creative Commons Attribution-NonCommercial 4.0 International License environment: IP-Symcon 4.0 (beta) on RPi changelog: version 1.0.0 28.12.2015 initialscript todo: (none) github: https://github.com/ubittner/SymconBoseSoundTouch.git symcon forum: https://www.symcon.de/forum/threads/29922-Bose-SoundTouch-Modul */ // variable definitions $instanceid = IPS_GetParent(IPS_GetParent($_IPS["SELF"])); $deviceip = IPS_GetProperty($instanceid, "DeviceIP"); $timeout = IPS_GetProperty($instanceid, "Timeout"); $alarmclockscriptid = IPS_GetScriptIDByName("AlarmClockControl", IPS_GetParent($_IPS["SELF"])); $alarmclockeventid = @IPS_GetEventIDByName("AlarmClockEvent", $alarmclockscriptid); $alarmclockcycleseconds = GetValue(IPS_GetObjectIDByName("Alarm Cycle", $instanceid)); // get actual device mode try { // check device availibility if ($timeout && Sys_Ping($deviceip, $timeout) != true) { throw new Exception("Device ".$deviceip." is not available"); } include_once("../modules/SymconBoseSoundTouch/Bose/bose_soundtouch_api.php"); $bosedevice = new BoseSoundTouchAPI($deviceip); // get device mode $result = $bosedevice->getDeviceNowPlayingAPI(); $devicemode = $result["devicemode"]; // get volume $result = $bosedevice->getDeviceVolumeAPI(); SetValue(IPS_GetObjectIDByName("Volume", $instanceid), $result["actualvolume"]); // power device on if ($devicemode == "Standby"){ $result = $bosedevice->powerDeviceAPI(); // set radio station $alarmradiostation = GetValue(IPS_GetObjectIDByName("Alarm Radio Station", $instanceid)); SetValue(IPS_GetObjectIDByName("Radio", $instanceid), $alarmradiostation); $associations = IPS_GetVariableProfile("bose.Device".$instanceid."RadioLocations")["Associations"]; foreach($associations as $key => $value) { if ($value["Value"] == $alarmradiostation) { $location = $value["Name"]; } } $result = $bosedevice->setDeviceRadioStationAPI($location); if ($alarmclockcycleseconds <> 0) { $volume = 1; $result = $bosedevice->setDeviceVolumeAPI($volume); SetValue(IPS_GetObjectIDByName("Volume", $instanceid), $volume); setNewEventCycleTime(); } else { switchAlarmClockOff(); } SetValue(IPS_GetObjectIDByName("Device Power", $instanceid), true); // get now playing getnowplaying: $result = $bosedevice->getDevicenowPlayingAPI(); if ($result["devicestate"] == "Reload") { goto getnowplaying; } SetValue(IPS_GetObjectIDByName("Device Mode", $instanceid), $result["devicemode"]); SetValue(IPS_GetObjectIDByName("Device State", $instanceid), $result["devicestate"]); SetValue(IPS_GetObjectIDByName("Now Playing", $instanceid), $result["nowplaying"]); SetValue(IPS_GetObjectIDByName("Description", $instanceid), $result["description"]); SetValue(IPS_GetObjectIDByName("Logo", $instanceid), $result["logourl"]); } // device is already on else { if ($alarmclockcycleseconds <> 0) { $actualvolume = GetValue(IPS_GetObjectIDByName("Volume", $instanceid)); $alarmclockvolume = GetValue(IPS_GetObjectIDByName("Alarm Clock Volume", $instanceid)); if ($actualvolume < $alarmclockvolume) { $targetvolume = ($actualvolume+1); $result = $bosedevice->setDeviceVolumeAPI($targetvolume); SetValue(IPS_GetObjectIDByName("Volume", $instanceid), $targetvolume); setNewEventCycleTime(); } else { switchAlarmClockOff(); } } } } // error message catch (Exception $e) { echo $e->getMessage(); } // set new event cycle time function setNewEventCycleTime() { global $alarmclockeventid, $alarmclockcycleseconds; $eventinfo = IPS_GetEvent($alarmclockeventid); $eventtimestamp = ($eventinfo["NextRun"]); $neweventtimestamp = strtotime("+ " .$alarmclockcycleseconds. " seconds", $eventtimestamp); $newhour = date("H",$neweventtimestamp); $newminute = date("i",$neweventtimestamp); $newsecond = date("s",$neweventtimestamp); IPS_SetEventCyclicTimeFrom($alarmclockeventid, $newhour, $newminute, $newsecond); IPS_SetEventActive($alarmclockeventid, true); } // switch alarm clock off function switchAlarmClockOff() { global $instanceid, $alarmclockeventid; SetValue(IPS_GetObjectIDByName("Alarm Clock", $instanceid), false); IPS_SetEventActive($alarmclockeventid, false); SetValue(IPS_GetObjectIDByName("Alarm Cycle", $instanceid), 0); SetValue(IPS_GetObjectIDByName("Next Power On", $instanceid), ""); } ?>'; // create script $alarmclockvariableid = @$this->GetIDForIdent("AlarmClock"); $alarmclockcontrolscriptid = @IPS_GetScriptIDByName("AlarmClockControl", $alarmclockvariableid); if ($alarmclockcontrolscriptid === false) { $alarmclockcontrolscriptid = $this->RegisterScript("AlarmClockControl", "AlarmClockControl", $AlarmClockControlScript, 0); } else { IPS_SetScriptContent($alarmclockcontrolscriptid, $AlarmClockControlScript); } IPS_SetParent($alarmclockcontrolscriptid, $alarmclockvariableid); IPS_SetHidden($alarmclockcontrolscriptid, true); $alarmclockscripteventid = @IPS_GetEventIDByName("AlarmClockEvent", $alarmclockcontrolscriptid); if ($alarmclockscripteventid == false) { $alarmclockscripteventid = IPS_CreateEvent(1); IPS_SetParent($alarmclockscripteventid, $alarmclockcontrolscriptid); IPS_SetName($alarmclockscripteventid, "AlarmClockEvent"); } // SleepTimer Script $SleepTimerControlScript = '<? /* SymconBoseSoundTouch Bose SoundTouch Module for IP-Symcon filename: SleepTimerControl.php description: Sleep Timer Control Script version 1.0.0 date: 28.12.2015 publisher: Copyright (c) 2015, 2016 Ulrich Bittner license: CC BY-NC 4.0 Creative Commons Attribution-NonCommercial 4.0 International License environment: IP-Symcon 4.0 (beta) on RPi changelog: version 1.0.0 28.12.2015 initialscript todo: (none) github: https://github.com/ubittner/SymconBoseSoundTouch.git symcon forum: https://www.symcon.de/forum/threads/29922-Bose-SoundTouch-Modul */ $instanceid = IPS_GetParent(IPS_GetParent($_IPS["SELF"])); $deviceip = IPS_GetProperty($instanceid, "DeviceIP"); $timeout = IPS_GetProperty($instanceid, "Timeout"); $sleepcycle = GetValue(IPS_GetObjectIDByName("Sleep Cycle", $instanceid)); $sleeptimerscriptid = IPS_GetScriptIDByName("SleepTimerControl", IPS_GetParent($_IPS["SELF"])); $sleeptimereventid = @IPS_GetEventIDByName("SleepTimerEvent", $sleeptimerscriptid); include_once("../modules/SymconBoseSoundTouch/Bose/bose_soundtouch_api.php"); try { // check device availibility if ($timeout && Sys_Ping($deviceip, $timeout) != true) { throw new Exception("Device ".$deviceip." is not available"); } $bosedevice = new BoseSoundTouchAPI($deviceip); $result = $bosedevice->getDevicenowPlayingAPI(); // device is on if ($result["devicestate"] == "Play"){ if ($sleepcycle <> 0) { decreaseVolume(); } else { switchDeviceOff(); } } // device is already off else { resetValues(); } } // error message catch (Exception $e) { echo $e->getMessage(); } // decrease volume function decreaseVolume() { global $deviceip, $timeout, $sleeptimereventid, $instanceid, $sleepcycle; try { // check device availibility if ($timeout && Sys_Ping($deviceip, $timeout) != true) { throw new Exception("Device ".$deviceip." is not available"); } $bosedevice = new BoseSoundTouchAPI($deviceip); $result = $bosedevice->getDeviceVolumeAPI(); if ($result["actualvolume"] == 1) { switchDeviceOff(); IPS_SetEventActive($sleeptimereventid, false); } else { $volume = ($result["actualvolume"])-1; $setvolume = $bosedevice->setDeviceVolumeAPI($volume); SetValue(IPS_GetObjectIDByName("Volume", $instanceid), $volume); $eventinfo = IPS_GetEvent($sleeptimereventid); $eventtimestamp = ($eventinfo["NextRun"]); $neweventtimestamp = strtotime("+ " . $sleepcycle . " seconds", $eventtimestamp); $newhour = date("H",$neweventtimestamp); $newminute = date("i",$neweventtimestamp); $newsecond = date("s",$neweventtimestamp); IPS_SetEventCyclicTimeFrom($sleeptimereventid, $newhour, $newminute, $newsecond); } } // error message catch (Exception $e) { echo $e->getMessage(); } } // switch device off function switchDeviceOff() { global $deviceip, $timeout; // power off try { if ($timeout && Sys_Ping($deviceip, $timeout) != true) { throw new Exception("Device ".$deviceip." is not available"); } $bosedevice = new BoseSoundTouchAPI($deviceip); $result = $bosedevice->powerDeviceAPI(); resetValues(); } // error message catch (Exception $e) { echo $e->getMessage(); } } // reset values function resetValues() { global $instanceid, $sleeptimereventid; SetValue(IPS_GetObjectIDByName("Device Power", $instanceid), false); SetValue(IPS_GetObjectIDByName("Device Mode", $instanceid), ""); SetValue(IPS_GetObjectIDByName("Device State", $instanceid), ""); SetValue(IPS_GetObjectIDByName("Now Playing", $instanceid), ""); SetValue(IPS_GetObjectIDByName("Description", $instanceid), ""); SetValue(IPS_GetObjectIDByName("Logo", $instanceid), ""); SetValue(IPS_GetObjectIDByName("Sleep Timer", $instanceid), false); SetValue(IPS_GetObjectIDByName("Volume Fade Out (15 min)", $instanceid), false); SetValue(IPS_GetObjectIDByName("Good Night (30 min)", $instanceid), false); SetValue(IPS_GetObjectIDByName("Sleep Cycle", $instanceid), 0); SetValue(IPS_GetObjectIDByName("Next Power Off", $instanceid), ""); IPS_SetEventActive($sleeptimereventid, false); } ?>'; $sleeptimervariableid = @$this->GetIDForIdent("SleepTimer"); $sleeptimercontrolscriptid = @IPS_GetScriptIDByName("SleepTimerControl", $sleeptimervariableid); if ($sleeptimercontrolscriptid === false) { $sleeptimercontrolscriptid = $this->RegisterScript("SleepTimerControl", "SleepTimerControl", $SleepTimerControlScript, 0); } else { IPS_SetScriptContent($sleeptimercontrolscriptid, $SleepTimerControlScript); } IPS_SetParent($sleeptimercontrolscriptid, $sleeptimervariableid); IPS_SetHidden($sleeptimercontrolscriptid, true); $sleeptimerscripteventid = @IPS_GetEventIDByName("SleepTimerEvent", $sleeptimercontrolscriptid); if ($sleeptimerscripteventid == false) { $sleeptimerscripteventid = IPS_CreateEvent(1); IPS_SetParent($sleeptimerscripteventid, $sleeptimercontrolscriptid); IPS_SetName($sleeptimerscripteventid, "SleepTimerEvent"); } }
/** * CreateFloatProfile * @param string $ProfileName * @param string $Icon * @param string $Präfix * @param string $Suffix * @param float $MinValue * @param float $MaxValue * @param integer $StepSize * @param integer $Digits */ private function CreateFloatProfile($ProfileName, $Icon, $Präfix, $Suffix, $MinValue, $MaxValue, $StepSize, $Digits) { $Profile = IPS_VariableProfileExists($ProfileName); if ($Profile === FALSE) { IPS_CreateVariableProfile($ProfileName, 2); IPS_SetVariableProfileIcon($ProfileName, $Icon); IPS_SetVariableProfileText($ProfileName, $Präfix, $Suffix); IPS_SetVariableProfileValues($ProfileName, $MinValue, $MaxValue, $StepSize); IPS_SetVariableProfileDigits($ProfileName, $Digits); } }
/** * overload internal IPS_Create($id) function */ public function Create() { // Diese Zeile nicht löschen. parent::Create(); //Hint: $this->debug will not work in this stage! must use IPS_LogMessage //props $this->RegisterPropertyString('Category', 'TE923 Devices'); $this->RegisterPropertyInteger('ParentCategory', 0); //parent cat is root $this->RegisterPropertyInteger('RainPerCount', self::rc_to_mm); $this->RegisterPropertyInteger('UpdateInterval', 600); $this->RegisterPropertyString('URL', 'http://raspberry/cgi-bin/get_data.cgi'); $this->RegisterPropertyString('LogFile', ''); $this->RegisterPropertyBoolean('AutoCreate', true); $this->RegisterPropertyBoolean('Debug', false); $this->RegisterPropertyBoolean('Active', false); //Vars $this->RegisterVariableInteger('NewDayRainCounter', 'Rain Counter at new Day', "", -1); $this->RegisterVariableInteger('LastRainCounter', 'Last Rain Counter', "", -2); $this->RegisterVariableInteger('TimeStamp', 'Device Timestamp', 'UnixTimestamp', -3); IPS_SetHidden($this->GetIDForIdent('LastRainCounter'), true); IPS_SetHidden($this->GetIDForIdent('NewDayRainCounter'), true); //reinit timer $this->RegisterTimer('Update', 0, $this->module_data["prefix"] . '_UpdateEvent($_IPS[\'TARGET\']);'); if (!IPS_VariableProfileExists('TE923_Storm')) { IPS_CreateVariableProfile('TE923_Storm', 0); //boolean IPS_SetVariableProfileValues('TE923_Storm', 0, 1, 0); //status is inverted because a 0 value is every time marked red, regardless of color IPS_SetVariableProfileAssociation('TE923_Storm', 1, "Not this", "Ok", -1); IPS_SetVariableProfileAssociation('TE923_Storm', 0, "Save your dog", "Warning", 16711680); IPS_SetVariableProfileIcon('TE923_Storm', "Warning"); } //Forecast $forecast = array(0 => array('Heavy Snow', 'Snowflake'), 1 => array('Little Snow', 'Snowflake'), 2 => array('Heavy Rain', 'Rainfall'), 3 => array('Little Rain', 'Drops'), 4 => array('Cloudy', 'Cloud'), 5 => array('some Clouds', 'Cloud'), 6 => array('Sunny', 'Sun')); if (!IPS_VariableProfileExists('TE923_Forecast')) { IPS_CreateVariableProfile('TE923_Forecast', 1); //integer IPS_SetVariableProfileValues('TE923_Forecast', 0, 6, 0); for ($i = 0; $i < 7; $i++) { IPS_SetVariableProfileAssociation('TE923_Forecast', $i, $forecast[$i][0], $forecast[$i][1], -1); } } if (IPS_GetKernelRunlevel() == self::KR_READY) { if ($this->isActive()) { $this->SetStatus(self::ST_AKTIV); $i = $this->GetUpdateInterval(); $this->SetTimerInterval('Update', $i * 1000); //ms $this->debug(__FUNCTION__, "Starte Timer {$i} sec"); } else { $this->SetStatus(self::ST_INACTIV); } } }
function CreateProfiles() { @IPS_CreateVariableProfile("IPSLogger_Level", 1); IPS_SetVariableProfileText("IPSLogger_Level", "", ""); IPS_SetVariableProfileValues("IPSLogger_Level", 0, 0, 0); IPS_SetVariableProfileDigits("IPSLogger_Level", 0); IPS_SetVariableProfileIcon("IPSLogger_Level", ""); IPS_SetVariableProfileAssociation("IPSLogger_Level", 0, "Fatal", "", 0xaaaaaa); IPS_SetVariableProfileAssociation("IPSLogger_Level", 1, "Error", "", 0xaaaaaa); IPS_SetVariableProfileAssociation("IPSLogger_Level", 2, "Warning", "", 0xaaaaaa); IPS_SetVariableProfileAssociation("IPSLogger_Level", 3, "Notification", "", 0xaaaaaa); IPS_SetVariableProfileAssociation("IPSLogger_Level", 4, "Info", "", 0xaaaaaa); IPS_SetVariableProfileAssociation("IPSLogger_Level", 5, "Debug", "", 0xaaaaaa); IPS_SetVariableProfileAssociation("IPSLogger_Level", 6, "Communication", "", 0xaaaaaa); IPS_SetVariableProfileAssociation("IPSLogger_Level", 7, "Trace", "", 0xaaaaaa); IPS_SetVariableProfileAssociation("IPSLogger_Level", 9, "All", "", 0xaaaaaa); @IPS_CreateVariableProfile("IPSLogger_MsgCount", 1); IPS_SetVariableProfileText("IPSLogger_MsgCount", "", " Msg's"); IPS_SetVariableProfileValues("IPSLogger_MsgCount", 5, 100, 5); IPS_SetVariableProfileDigits("IPSLogger_MsgCount", 0); IPS_SetVariableProfileIcon("IPSLogger_MsgCount", ""); @IPS_CreateVariableProfile("IPSLogger_MsgId", 1); IPS_SetVariableProfileText("IPSLogger_MsgId", "", ""); IPS_SetVariableProfileValues("IPSLogger_MsgId", 0, 0, 0); IPS_SetVariableProfileDigits("IPSLogger_MsgId", 0); IPS_SetVariableProfileIcon("IPSLogger_MsgId", ""); @IPS_CreateVariableProfile("IPSLogger_Delay", 1); IPS_SetVariableProfileText("IPSLogger_Delay", "", " Seconds"); IPS_SetVariableProfileValues("IPSLogger_Delay", 0, 600, 30); IPS_SetVariableProfileDigits("IPSLogger_Delay", 0); IPS_SetVariableProfileIcon("IPSLogger_Delay", ""); @IPS_CreateVariableProfile("IPSLogger_Days", 1); IPS_SetVariableProfileText("IPSLogger_Days", "", " Tage"); IPS_SetVariableProfileValues("IPSLogger_Days", 0, 100, 5); IPS_SetVariableProfileDigits("IPSLogger_Days", 0); IPS_SetVariableProfileIcon("IPSLogger_Days", ""); @IPS_CreateVariableProfile("IPSLogger_Priority", 1); IPS_SetVariableProfileText("IPSLogger_Priority", "", ""); IPS_SetVariableProfileValues("IPSLogger_Priority", 0, 10, 1); IPS_SetVariableProfileDigits("IPSLogger_Priority", 0); IPS_SetVariableProfileIcon("IPSLogger_Priority", ""); }
/** * Check profile by name if exists, else create * @param String $pname Name * @param integer $typ Variable Typ (0..3) * @param String $prefix Prefix before value * @param String $suffix Suffix after value * @param String $icon Icon Name * @param integer $min min value * @param integer $max max value * @param integer $step step value * @param integer $digit digits for formatting * @param boolean $drop drop existing profile first */ protected function check_profile($pname, $typ, $prefix, $suffix, $icon, $min, $max, $step, $digit = 0, $drop = false) { //use logmessages instead of debug because this isnt available in early stage if (IPS_VariableProfileExists($pname) && $drop) { IPS_DeleteVariableProfile($pname); } if (!IPS_VariableProfileExists($pname)) { IPS_LogMessage($this->name, __FUNCTION__ . "(#" . $this->InstanceID . ") Create VariableProfile {$pname}"); if (IPS_CreateVariableProfile($pname, $typ)) { IPS_SetVariableProfileText($pname, $prefix, $suffix); if (isset($min) && isset($max) && isset($step)) { IPS_SetVariableProfileValues($pname, $min, $max, $step); } if (isset($digit)) { IPS_SetVariableProfileDigits($pname, $digit); } if ($icon) { IPS_SetVariableProfileIcon($pname, $icon); } } else { IPS_LogMessage($this->name, __FUNCTION__ . "(#" . $this->InstanceID . ") Cannot Create VariableProfile {$pname}"); } } }
function CreateProfile_Duration ($Name, $Start, $Step, $Stop, $Prefix=" Min", $Icon="") { @IPS_DeleteVariableProfile($Name); IPS_CreateVariableProfile($Name, 1); IPS_SetVariableProfileText($Name, "", $Prefix); IPS_SetVariableProfileValues($Name, $Start, $Stop, $Step); IPS_SetVariableProfileDigits($Name, 0); IPS_SetVariableProfileIcon($Name, $Icon); }