function Entertainment_SetRoomControlVisibility($RoomControlId, $Value) { $RoomName = IPS_GetName(IPS_GetParent($RoomControlId)); $RoomConfig = get_RoomConfiguration(); $ControlName = IPS_GetName($RoomControlId); $WFRoomName = $RoomConfig[$RoomName][c_Property_Name]; if ($WFRoomName=="") return; $WFRoomId = IPS_GetCategoryIDByName($WFRoomName, c_ID_WebFrontRoomes); $WFControlId = false; $ChildrenIds = IPS_GetChildrenIDs($WFRoomId); foreach($ChildrenIds as $ChildrenIdx => $ChildrenId) { if (IPS_LinkExists($ChildrenId)) { if (IPS_GetName($ChildrenId)==$ControlName) { $WFControlId = $ChildrenId; } } else { $WFControlId = @IPS_GetLinkIDByName($ControlName, $WFRoomId); } } if ($WFControlId!==false) { $WFControl=IPS_GetObject($WFControlId); if ($WFControl['ObjectIsHidden']<> !$Value) { IPS_SetHidden($WFControlId, !$Value); } } }
protected function RegisterTimer($ident, $interval, $script) { $id = @IPS_GetObjectIDByIdent($ident, $this->InstanceID); if ($id && IPS_GetEvent($id)['EventType'] <> 1) { IPS_DeleteEvent($id); $id = 0; } if (!$id) { $id = IPS_CreateEvent(1); IPS_SetParent($id, $this->InstanceID); IPS_SetIdent($id, $ident); } IPS_SetName($id, $ident); IPS_SetHidden($id, true); IPS_SetEventScript($id, "\$id = \$_IPS['TARGET'];\n$script;"); if (!IPS_EventExists($id)) throw new Exception("Ident with name $ident is used for wrong object type"); if (!($interval > 0)) { IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, 1); IPS_SetEventActive($id, false); } else { IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $interval); IPS_SetEventActive($id, true); } }
/** * overload internal IPS_Create($id) function */ public function Create() { parent::Create(); //Hint: $this->debug will not work in this stage! must use IPS_LogMessage //props $this->RegisterPropertyString('Category', 'CUL/CUx Devices'); $this->RegisterPropertyInteger('ParentCategory', 0); //parent cat is root $this->RegisterPropertyBoolean('AutoCreate', true); $this->RegisterPropertyBoolean('Debug', false); $this->RegisterPropertyBoolean('Active', false); $this->RegisterPropertyBoolean('UseOW', false); //status Vars $this->RegisterVariableString('Buffer', 'Buffer', "", -1); IPS_SetHidden($this->GetIDForIdent('Buffer'), true); $this->RegisterVariableString('LastUpdate', 'Last Update', "", -2); IPS_SetHidden($this->GetIDForIdent('LastUpdate'), true); $this->RegisterVariableString('AuxMessage', 'Last System Message', "", 1); $this->RegisterVariableString('Version', 'Version', "", 2); $this->RegisterVariableString('Modus', 'Modus', "", 2); $this->RegisterVariableInteger('Errors', 'Errors', 0, 3); //reinit timer $this->RegisterTimer('ReInit', 58000, $this->module_data["prefix"] . '_ReInitEvent($_IPS[\'TARGET\']);'); //call init if ready and activated if (IPS_GetKernelRunlevel() == self::KR_READY) { if ($this->isActive()) { $this->SetStatus(self::ST_AKTIV); //$this->init(); } else { $this->SetStatus(self::ST_INACTIV); } } }
public function ApplyChanges() { //Never delete this line! parent::ApplyChanges(); $this->RegisterVariableString("BufferIN", "BufferIN", "", -7); $this->RegisterVariableString("Dataset", "Dataset", "", -6); $this->RegisterVariableInteger("Sensoren", "Sensoren", "", -5); IPS_SetHidden($this->GetIDForIdent('BufferIN'), true); IPS_SetHidden($this->GetIDForIdent('Dataset'), true); $this->RegisterVariableString("Sensor1_ROM", "Sensor1_ROM", "", 5); $Sensor1_ROMID = $this->GetIDForIdent("Sensor1_ROM"); $this->RegisterVariableString("Sensor1_Typ", "Sensor1_Typ", "", 6); $Sensor1_TypID = $this->GetIDForIdent("Sensor1_Typ"); $this->RegisterVariableFloat("Sensor1_Temp", "Sensor1_Temp", "~Temperature", 7); $Sensor1_TempID = $this->GetIDForIdent("Sensor1_Temp"); $this->RegisterVariableString("Sensor2_ROM", "Sensor2_ROM", "", 8); $Sensor2_ROMID = $this->GetIDForIdent("Sensor2_ROM"); $this->RegisterVariableString("Sensor2_Typ", "Sensor2_Typ", "", 9); $Sensor2_TypID = $this->GetIDForIdent("Sensor2_Typ"); $this->RegisterVariableFloat("Sensor2_Temp", "Sensor2_Temp", "~Temperature", 10); $Sensor2_TempID = $this->GetIDForIdent("Sensor2_Temp"); $this->RegisterVariableString("Sensor3_ROM", "Sensor3_ROM", "", 11); $Sensor3_ROMID = $this->GetIDForIdent("Sensor3_ROM"); $this->RegisterVariableString("Sensor3_Typ", "Sensor3_Typ", "", 12); $Sensor3_TypID = $this->GetIDForIdent("Sensor3_Typ"); $this->RegisterVariableFloat("Sensor3_Temp", "Sensor3_Temp", "~Temperature", 13); $Sensor3_TempID = $this->GetIDForIdent("Sensor3_Temp"); // IPS_SetParent($Sensor1_ROMID, $Dummymodul_1_ID); // Instanz einsortieren unter dem Objekt }
public function ApplyChanges() { //Never delete this line! parent::ApplyChanges(); $this->RegisterVariableBoolean("IsHoliday", "Is Holiday"); $this->RegisterVariableString("Holiday", "Feiertag"); $this->SetTimerInterval("UpdateTimer", $this->ReadPropertyInteger("timerinterval") * 60 * 60 * 1000); // Set Hidden IPS_SetHidden($this->GetIDForIdent("IsHoliday"), true); $this->Update(); }
public function ApplyChanges() { parent::ApplyChanges(); $this->RegisterVariableInteger("TransmitStatus", "TransmitStatus", "", -3); $this->RegisterVariableInteger("FrameID", "FrameID", "", -2); IPS_SetHidden($this->GetIDForIdent('TransmitStatus'), true); IPS_SetHidden($this->GetIDForIdent('FrameID'), true); if ($this->ReadPropertyString('NodeName') == '') { $this->SetSummary(202); } else { $this->SetStatus(102); } $this->SetSummary($this->ReadPropertyString('NodeName')); }
/** * 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', 'NUT Devices'); $this->RegisterPropertyInteger('ParentCategory', 0); //parent cat is root $this->RegisterPropertyInteger('Port', 3493); $this->RegisterPropertyInteger('UpdateInterval', 300); $this->RegisterPropertyInteger('NomPower', self::default_nomval); $this->RegisterPropertyString('IDfield', 'ups.serial'); $this->RegisterPropertyString('UPSname', ''); $this->RegisterPropertyString('Host', ''); $this->RegisterPropertyString('LogFile', ''); $this->RegisterPropertyBoolean('AutoCreate', true); $this->RegisterPropertyBoolean('Debug', false); $this->RegisterPropertyBoolean('Active', false); //timer $this->RegisterTimer('Update', 0, $this->module_data["prefix"] . '_UpdateEvent($_IPS[\'TARGET\']);'); //Vars $this->RegisterVariableString('Buffer', 'Buffer', "", -1); IPS_SetHidden($this->GetIDForIdent('Buffer'), true); //Connect Parent $this->RequireParent($this->module_interfaces['ClientSocket']); $pid = $this->GetParent(); if ($pid) { $name = IPS_GetName($pid); if ($name == "Client Socket") { IPS_SetName($pid, __CLASS__ . " Socket"); } } if (IPS_GetKernelRunlevel() == self::KR_READY) { if ($this->isActive() && $this->GetParent() > 0) { $this->SetStatus(self::ST_AKTIV); $i = $this->GetUpdateInterval(); $this->SetTimerInterval('Update', $i * 1000); //ms $this->debug(__FUNCTION__, "Starte Timer {$i} sec"); $this->init(); } else { $this->SetStatus(self::ST_INACTIV); } } }
public function ApplyChanges() { //Never delete this line! parent::ApplyChanges(); if ($this->ReadPropertyString('Bus') == '') { $this->SetStatus(202); } else { $this->SetStatus(102); } $this->RegisterVariableString('Monitordaten', 'Monitordaten', '', -4); IPS_SetHidden($this->GetIDForIdent('Monitordaten'), true); $this->RegisterVariableString('EinstellPar', 'EinstellPar', '', -4); IPS_SetHidden($this->GetIDForIdent('EinstellPar'), true); $this->RegisterProfile('Minutes', '2', '', '', ' m', 0, 0, 0); $this->RegisterProfile('Hours', '2', '', '', ' h', 0, 0, 0); $this->RegisterProfile('Watt', '2', '', '', ' kWh', 0, 0, 0); $this->RegisterProfile('Waerme', '2', '', '', ' Wh', 0, 0, 0); $this->RegisterProfile('Version', '3', '', 'V ', '', 0, 0, 0); $this->RegisterProfile('Flow', '2', '', '', ' l/h', 0, 0, 0); }
/** * 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', 'WDE1 Devices'); $this->RegisterPropertyInteger('ParentCategory', 0); //parent cat is root $this->RegisterPropertyString('LogFile', ''); $this->RegisterPropertyInteger('RainPerCount', 295); $this->RegisterPropertyBoolean('AutoCreate', true); $this->RegisterPropertyBoolean('Debug', false); $this->RegisterPropertyBoolean('Active', false); //Vars $this->RegisterVariableString('Buffer', 'Buffer', "", -1); IPS_SetHidden($this->GetIDForIdent('Buffer'), true); $this->RegisterVariableString('LastUpdate', 'Last Update', "", -4); IPS_SetHidden($this->GetIDForIdent('LastUpdate'), true); //Timers $this->RegisterTimer('ReInit', 60000, $this->module_data["prefix"] . '_ReInitEvent($_IPS[\'TARGET\']);'); //Connect Parent $this->RequireParent($this->module_interfaces['SerialPort']); $pid = $this->GetParent(); if ($pid) { $name = IPS_GetName($pid); if ($name == "Serial Port") { IPS_SetName($pid, __CLASS__ . " Port"); } } //call init if ready and activated if (IPS_GetKernelRunlevel() == self::KR_READY) { if ($this->isActive()) { $this->SetStatus(self::ST_AKTIV); $this->init(); } else { $this->SetStatus(self::ST_INACTIV); $this->SetTimerInterval('ReInit', 0); } } }
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() { // Diese Zeile nicht löschen parent::ApplyChanges(); if (strlen($this->ReadPropertyString("API")) == 16) { //Instanz ist aktiv $this->SetStatus(102); //Script + Timer $UpdateInterval = $this->ReadPropertyInteger("UpdateInterval"); IPS_LogMessage($_IPS['SELF'], "Update Interval " . $UpdateInterval . " Minuten"); $UpdateWeatherScriptID = @$this->GetIDForIdent("_updateWeather"); if ($UpdateWeatherScriptID === false) { $UpdateWeatherScriptID = $this->RegisterScript("_updateWeather", "_updateWeather", file_get_contents(__DIR__ . "/_updateWeather.php"), 99); } else { IPS_SetScriptContent($UpdateWeatherScriptID, file_get_contents(__DIR__ . "/_updateWeather.php")); } IPS_SetHidden($UpdateWeatherScriptID, true); IPS_SetScriptTimer($UpdateWeatherScriptID, $UpdateInterval); } else { //Instanz ist inaktiv $this->SetStatus(104); } }
/** * 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', 'WS2500 Devices'); $this->RegisterPropertyInteger('ParentCategory', 0); //parent cat is root $this->RegisterPropertyInteger('RainPerCount', 295); $this->RegisterPropertyInteger('UpdateInterval', 1800); $this->RegisterPropertyString('URL', 'http://raspberry/cgi-bin/get_ws2500_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); $this->RegisterVariableInteger('Block', 'Block Number', '', -1); 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_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); } } }
protected function SetHidden($Ident, $value) { $id = $this->GetIDForIdent($Ident); IPS_SetHidden($id, $value); }
private function CreateDevices() { // Create Variables Profiles // From Foobot: ["time","pm","tmp","hum","co2","voc","allpollu"],"units":["s","ugm3","C","pc","ppm","ppb","%"] [1445275154,45.449997,25.754375,39.512215,1033.0,286.0,62.60714] $this->RegisterProfileIntegerEx("Pollutant.Co2", "Gauge", "", " ppm", array(array(0, "%d", "", 0xff00), array(1000, "%d", "", 0xffff00), array(2000, "%d", "", 0xff0000))); $this->RegisterProfileFloatEx("Pollutant.PM", "Gauge", "", " uG/m3", array(array(0, "%.1f", "", 0xff00), array(25, "%.1f", "", 0xff0000))); $this->RegisterProfileIntegerEx("Pollutant.VC", "Gauge", "", " ppb", array(array(0, "%d", "", 0xff00), array(500, "%d", "", 0xff0000))); $this->RegisterProfileFloatEx("Pollutant.GPI", "Gauge", "", " %", array(array(0, "%.1f", "", 0xff00), array(50, "%.1f", "", 0xffff00), array(100, "%.1f", "", 0xff0000))); // Get Foobot devices from API and loop on them to create Instances and Variables $devices = $this->GetDevices(); if ($devices !== false) { //foreach ($devices as $device) { // Prepared for multiple Foobot devices support - to be tested // Create a dummy Instance for each Foobot Sensor if it does not exist already if (!$this->deviceInstanceExists($devices->name)) { $FBdeviceModuleID = IPS_CreateInstance("{485D0419-BE97-4548-AA9C-C083EB82E61E}"); IPS_SetName($FBdeviceModuleID, $devices->name); IPS_SetParent($FBdeviceModuleID, $this->InstanceID); $this->RegisterVariableString("Uuid", "Device UUID", "~String", 1); SetValue($this->GetIDForIdent('Uuid'), $devices->uuid); IPS_SetHidden($this->GetIDForIdent('Uuid'), true); IPS_SetParent($this->GetIDForIdent('Uuid'), $FBdeviceModuleID); $this->RegisterVariableString("Mac", "Device Mac", "~String", 2); SetValue($this->GetIDForIdent('Mac'), $devices->mac); IPS_SetHidden($this->GetIDForIdent('Mac'), true); IPS_SetParent($this->GetIDForIdent('Mac'), $FBdeviceModuleID); // Create Variables $this->RegisterVariableInteger("Co2", "Carbon Dioxide", "Pollutant.Co2", 10); IPS_SetParent($this->GetIDForIdent('Co2'), $FBdeviceModuleID); $this->RegisterVariableInteger("Voc", "Volatile compounds", "Pollutant.VC", 11); IPS_SetParent($this->GetIDForIdent('Voc'), $FBdeviceModuleID); $this->RegisterVariableFloat("Pm", "PM2.5", "Pollutant.PM", 12); IPS_SetParent($this->GetIDForIdent('Pm'), $FBdeviceModuleID); $this->RegisterVariableFloat("Allpollu", "Global Pollution Index", "Pollutant.GPI", 13); IPS_SetParent($this->GetIDForIdent('Allpollu'), $FBdeviceModuleID); $this->RegisterVariableFloat("Tmp", "Temperature", "~Temperature", 14); IPS_SetParent($this->GetIDForIdent('Tmp'), $FBdeviceModuleID); $this->RegisterVariableFloat("Hum", "Humidity", "~Humidity.F", 15); IPS_SetParent($this->GetIDForIdent('Hum'), $FBdeviceModuleID); } //} // End of loop on devices return true; } else { $this->SetStatus(203); if ($this->debug) { IPS_LogMessage("FOOBOT Module", "ERROR: No Foobot Devices have been found!"); } return false; } }
public function ApplyChanges() { //Never delete this line! parent::ApplyChanges(); $ChangeParentSetting = false; $Open = $this->ReadPropertyBoolean('Open'); $NewState = IS_ACTIVE; if (!$Open) { $NewState = IS_INACTIVE; } if ($this->ReadPropertyString('Host') == '') { if ($Open) { $NewState = IS_EBASE + 2; $Open = false; } } if ($this->ReadPropertyString('Port') == '') { if ($Open) { $NewState = IS_EBASE + 2; $Open = false; } } // Zwangskonfiguration des ClientSocket $ParentID = $this->GetParent(); if ($ParentID > 0) { if (IPS_GetProperty($ParentID, 'Host') != $this->ReadPropertyString('Host')) { IPS_SetProperty($ParentID, 'Host', $this->ReadPropertyString('Host')); // $ChangeParentSetting = true; } if (IPS_GetProperty($ParentID, 'Port') != $this->ReadPropertyInteger('Port')) { IPS_SetProperty($ParentID, 'Port', $this->ReadPropertyInteger('Port')); // $ChangeParentSetting = true; } // Keine Verbindung erzwingen wenn Host leer ist, sonst folgt später Exception. if ($Open) { $Open = @Sys_Ping($this->ReadPropertyString('Host'), 500); if (!$Open) { $NewState = IS_EBASE + 3; } } if (IPS_GetProperty($ParentID, 'Open') != $Open) { IPS_SetProperty($ParentID, 'Open', $Open); // $ChangeParentSetting = true; } if (IPS_HasChanges($ParentID)) { @IPS_ApplyChanges($ParentID); if (!$this->HasActiveParent($ParentID) and $Open) { $NewState = IS_EBASE + 3; } } } else { if ($Open) { $NewState = IS_INACTIVE; $Open = false; } } // Eigene Profile $this->RegisterProfileIntegerEx("Scanner.SqueezeboxServer", "Gear", "", "", array(array(0, "Standby", "", -1), array(1, "Abbruch", "", -1), array(2, "Scan", "", -1), array(3, "Nur Playlists", "", -1), array(4, "Vollständig", "", -1))); $this->RegisterProfileInteger("PlayerSelect" . $this->InstanceID . ".SqueezeboxServer", "Speaker", "", "", 0, 0, 0); // Eigene Variablen $this->RegisterVariableInteger("RescanState", "Scanner", "Scanner.SqueezeboxServer", 1); $this->RegisterVariableString("RescanInfo", "Rescan Status", "", 2); $this->RegisterVariableString("RescanProgress", "Rescan Fortschritt", "", 3); $this->EnableAction("RescanState"); $this->RegisterVariableInteger("PlayerSelect", "Player wählen", "PlayerSelect" . $this->InstanceID . ".SqueezeboxServer", 4); $this->EnableAction("PlayerSelect"); $this->RegisterVariableString("Playlists", "Playlisten", "~HTMLBox", 5); // Eigene Scripte $ID = $this->RegisterScript("WebHookPlaylist", "WebHookPlaylist", $this->CreateWebHookScript(), -8); IPS_SetHidden($ID, true); if (IPS_GetKernelRunlevel() == KR_READY) { $this->RegisterHook('/hook/LMSPlaylist' . $this->InstanceID, $ID); } $ID = $this->RegisterScript('PlaylistDesign', 'Playlist Config', $this->CreatePlaylistConfigScript(), -7); IPS_SetHidden($ID, true); //Workaround für persistente Daten der Instanz $this->RegisterVariableString("BufferIN", "BufferIN", "", -3); $this->RegisterVariableString("BufferOUT", "BufferOUT", "", -2); $this->RegisterVariableBoolean("WaitForResponse", "WaitForResponse", "", -1); IPS_SetHidden($this->GetIDForIdent('BufferIN'), true); IPS_SetHidden($this->GetIDForIdent('BufferOUT'), true); IPS_SetHidden($this->GetIDForIdent('WaitForResponse'), true); // Wenn wir verbunden sind, am LMS mit listen anmelden für Events if ($Open and $this->HasActiveParent($ParentID)) { switch (IPS_GetKernelRunlevel()) { case KR_READY: $hasNewState = $this->SetStatus($NewState); if ($NewState == IS_ACTIVE and $hasNewState === true) { try { $Data = new LMSData("listen", "1"); $this->SendLMSData($Data); $this->RefreshPlayerList(); $Data = new LMSData("rescan", "?", false); $this->SendLMSData($Data); } catch (Exception $exc) { trigger_error($exc->getMessage(), $exc->getCode()); return false; } $DevicesIDs = IPS_GetInstanceListByModuleID("{118189F9-DC7E-4DF4-80E1-9A4DF0882DD7}"); foreach ($DevicesIDs as $Device) { if (IPS_GetInstance($Device)['ConnectionID'] == $this->InstanceID) { @IPS_ApplyChanges($Device); } } } break; case KR_INIT: if ($NewState == IS_ACTIVE) { $this->SetStatus(IS_EBASE + 3); } else { $this->SetStatus($NewState); } break; } } else { $this->SetStatus($NewState); } }
protected function SetHiddenOrDisabled($ObjectID, $Value) { if (IPS_GetObject($ObjectID)["ObjectIsHidden"] != $Value) { IPS_SetHidden($ObjectID, $Value); } }
public function SetValue($key, $value) { $stateId = IPS_GetObjectIDByIdent('STATE', $this->InstanceID); $cmId = IPS_GetObjectIDByIdent('COLOR_MODE', $this->InstanceID); $ctId = @IPS_GetObjectIDByIdent('COLOR_TEMPERATURE', $this->InstanceID); $briId = IPS_GetObjectIDByIdent('BRIGHTNESS', $this->InstanceID); $satId = @IPS_GetObjectIDByIdent('SATURATION', $this->InstanceID); $hueId = @IPS_GetObjectIDByIdent('HUE', $this->InstanceID); $colorId = @IPS_GetObjectIDByIdent('COLOR', $this->InstanceID); $stateValue = GetValueBoolean($stateId); $cmValue = $cmId ? GetValueInteger($cmId) : 0; $ctValue = $ctId ? (500 - round(347 * GetValueInteger($ctId) / 100)) : 0; $briValue = round(GetValueInteger($briId)*2.54); $satValue = $satId ? round(GetValueInteger($satId)*2.54) : 0; $hueValue = $hueId ? GetValueInteger($hueId) : 0; $colorValue = $colorId ? GetValueInteger($colorId) : 0; switch ($key) { case 'STATE': $stateNewValue = $value; break; case 'COLOR': $colorNewValue = $value; $stateNewValue = true; $hex = str_pad(dechex($value), 6, 0, STR_PAD_LEFT); $hsv = $this->HEX2HSV($hex); SetValueInteger($colorId, $value); $hueNewValue = $hsv['h']; $briNewValue = $hsv['v']; $satNewValue = $hsv['s']; $cmNewValue = 0; break; case 'BRIGHTNESS': $briNewValue = $value; $stateNewValue = true; if (IPS_GetProperty($this->InstanceID, 'LightFeatures') != 3) { if ($cmValue == '0') { $newHex = $this->HSV2HEX($hueValue, $satValue, $briNewValue); SetValueInteger($colorId, hexdec($newHex)); $hueNewValue = $hueValue; $satNewValue = $satValue; } else { $ctNewValue = $ctValue; } } break; case 'SATURATION': $cmNewValue = 0; $satNewValue = $value; $stateNewValue = true; $newHex = $this->HSV2HEX($hueValue, $satNewValue, $briValue); SetValueInteger($colorId, hexdec($newHex)); $hueNewValue = $hueValue; $briNewValue = $briValue; break; case 'COLOR_TEMPERATURE': $cmNewValue = 1; $ctNewValue = $value; $briNewValue = $briValue; break; case 'COLOR_MODE': $cmNewValue = $value; $stateNewValue = true; if ($cmNewValue == 1) { $ctNewValue = $ctValue; IPS_SetHidden($colorId, true); IPS_SetHidden($ctId, false); IPS_SetHidden($satId, true); } else { $hueNewValue = $hueValue; $satNewValue = $satValue; $briNewValue = $briValue; $newHex = $this->HSV2HEX($hueValue, $satValue, $briValue); SetValueInteger($colorId, hexdec($newHex)); IPS_SetHidden($colorId, false); IPS_SetHidden($ctId, true); IPS_SetHidden($satId, false); } break; } $changes = array(); if (isset($stateNewValue)) { SetValueBoolean($stateId, $stateNewValue); $changes['on'] = $stateNewValue; } if (isset($hueNewValue)) { SetValueInteger($hueId, $hueNewValue); $changes['hue'] = $hueNewValue; } if (isset($satNewValue)) { SetValueInteger($satId, round($satNewValue * 100 / 254)); $changes['sat'] = $satNewValue; } if (isset($briNewValue)) { SetValueInteger($briId, round($briNewValue * 100 / 254)); $changes['bri'] = $briNewValue; } if (isset($ctNewValue)) { SetValueInteger($ctId, 100 - round(($ctNewValue - 153) * 100 / 347)); $changes['ct'] = $ctNewValue; } if (isset($cmNewValue)) { SetValueInteger($cmId, $cmNewValue); $changes['colormode'] = $cmNewValue == 1 ? 'ct' : 'hs'; } $lightId = $this->ReadPropertyInteger("LightId"); return HUE_Request($this->GetBridge(), "/lights/$lightId/state", $changes); }
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']); } } if ($DeviceHidden) { IPS_SetHidden($HMDevice, true); } } $HMNewAdresses[] = (string) $Channel['Address']; } /* if (!isset($HMNewAdresses)) die("Keine neuen Geräte gefunden!"); var_dump($HMNewAdresses); */ } function ReadCCUInterfaces($ip) { $Script = ' string index; ! Indexvariable WriteLine("<xml>"); string SysVars=dom.GetObject(ID_INTERFACES).EnumUsedIDs(); foreach (index, SysVars)
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"); } }
/** * ModBusMaster_WriteCoil * @param boolean $Value * @return boolean */ public function WriteCoil($Value) { if ($this->ReadPropertyBoolean("ReadOnly")) { trigger_error("Address is marked as read-only!", E_USER_WARNING); return; } if ($this->ReadPropertyInteger("DataType") === 0) { $resultat = $this->SendDataToParent(json_encode(array("DataID" => "{A3419A88-C83B-49D7-8706-D3AFD596DFBB}", "FC" => "5", "Address" => $this->ReadPropertyInteger("Address"), "Data" => $Value))); if ($this->ReadPropertyInteger("SwitchDuration") > 0 and $Value) { $eid = @IPS_GetObjectIDByIdent("SwitchDuration", $this->InstanceID); if ($eid === false) { $eid = 0; } else { if (IPS_GetEvent($eid)['EventType'] != 1) { IPS_DeleteEvent($eid); $eid = 0; } } if ($eid == 0) { $eid = IPS_CreateEvent(1); IPS_SetParent($eid, $this->InstanceID); IPS_SetIdent($eid, "SwitchDuration"); IPS_SetName($eid, "SwitchDuration"); IPS_SetHidden($eid, true); IPS_SetEventScript($eid, "ModBusMaster_WriteCoil(\$_IPS['TARGET'], false);IPS_SetEventActive(\$_IPS['EVENT'],false);"); } IPS_SetEventCyclicTimeFrom($eid, date("H"), date("i"), date("s")); IPS_SetEventCyclic($eid, 0, 0, 0, 0, 1, $this->ReadPropertyInteger("SwitchDuration")); IPS_SetEventActive($eid, true); } return $resultat; } else { trigger_error("Invalid DataType!", E_USER_WARNING); } }
/** * 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', 'WS300PC Devices'); $this->RegisterPropertyInteger('ParentCategory', 0); //parent cat is root $this->RegisterPropertyInteger('RecordInterval', 5); $this->RegisterPropertyInteger('WS300PCInterval', 300); $this->RegisterPropertyString('LogFile', ''); //$this->RegisterPropertyString('WSWinFile', ''); $this->RegisterPropertyInteger('Altitude', 0); $this->RegisterPropertyInteger('RainPerCount', 295); $this->RegisterPropertyBoolean('AutoCreate', true); $this->RegisterPropertyBoolean('Debug', false); $this->RegisterPropertyBoolean('Active', false); //willi profile if (!IPS_VariableProfileExists('WS300_Willi')) { IPS_CreateVariableProfile('WS300_Willi', 1); //integer IPS_SetVariableProfileAssociation('WS300_Willi', 0, 'Sunny', 'Sun', -1); IPS_SetVariableProfileAssociation('WS300_Willi', 1, 'some Clouds', 'Cloud', -1); IPS_SetVariableProfileAssociation('WS300_Willi', 2, 'Cloudy', 'Cloud', -1); IPS_SetVariableProfileAssociation('WS300_Willi', 3, 'Rainy', 'Drops', -1); } //Vars $this->RegisterVariableInteger('RecCount', 'History Record Count'); $this->RegisterVariableString('Last', 'Last History Record'); $this->RegisterVariableString('Buffer', 'Buffer', "", -1); IPS_SetHidden($this->GetIDForIdent('Buffer'), true); $this->RegisterVariableBoolean('isPolling', 'isPolling', "", -2); IPS_SetHidden($this->GetIDForIdent('isPolling'), true); $this->RegisterVariableString('Config', 'Config Record', "", -3); IPS_SetHidden($this->GetIDForIdent('Config'), true); $this->RegisterVariableString('LastUpdate', 'Last Update', "", -4); IPS_SetHidden($this->GetIDForIdent('LastUpdate'), true); //Timers $this->RegisterTimer('ReInit', 60000, $this->module_data["prefix"] . '_ReInitEvent($_IPS[\'TARGET\']);'); $this->RegisterTimer('Update', 0, $this->module_data["prefix"] . '_UpdateEvent($_IPS[\'TARGET\']);'); //Connect Parent $this->RequireParent($this->module_interfaces['SerialPort']); $pid = $this->GetParent(); if ($pid) { $name = IPS_GetName($pid); if ($name == "Serial Port") { IPS_SetName($pid, __CLASS__ . " Port"); } } //call init if ready and activated if (IPS_GetKernelRunlevel() == self::KR_READY) { if ($this->isActive() && $this->HasActiveParent()) { $this->SetStatus(self::ST_AKTIV); $i = $this->GetWS300pcInterval(); $this->SetTimerInterval('Update', $i * 1000); //ms $this->SetTimerInterval('ReInit', 60000); $this->init(); SetValueInteger($this->GetIDForIdent('RecCount'), 0); $this->GetWS300pcInterval(); } else { $this->SetStatus(self::ST_INACTIV); $this->SetTimerInterval('ReInit', 0); $this->SetTimerInterval('Update', 0); } } }
protected function RegisterTimer($Ident, $Milliseconds, $Action) { $id = @IPS_GetObjectIDByIdent($Ident, $this->InstanceID); if ($id === false) { $id = 0; } if ($id > 0) { if (!IPS_EventExists($id)) { throw new Exception("Ident with name " . $Ident . " is used for wrong object type"); } if (IPS_GetEvent($id)['EventType'] != 1) { IPS_DeleteEvent($id); $id = 0; } } if ($id == 0) { $id = IPS_CreateEvent(1); IPS_SetParent($id, $this->InstanceID); IPS_SetIdent($id, $Ident); } IPS_SetName($id, $Ident); IPS_SetHidden($id, true); IPS_SetEventScript($id, $Action); IPS_SetEventActive($id, false); }
protected function RegisterEvent($Name, $Source, $Script) { $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID); if ($id === false) { $id = 0; } if ($id > 0) { if (!IPS_EventExists($id)) { throw new Exception("Ident with name " . $Name . " is used for wrong object type", E_USER_WARNING); } if (IPS_GetEvent($id)['EventType'] != 0) { IPS_DeleteEvent($id); $id = 0; } } if ($id == 0) { $id = IPS_CreateEvent(0); IPS_SetParent($id, $this->InstanceID); IPS_SetIdent($id, $Name); } IPS_SetName($id, $Name); IPS_SetHidden($id, true); IPS_SetEventScript($id, $Script); if ($Source > 0) { IPS_SetEventTrigger($id, 0, $Source); if (!IPS_GetEvent($id)['EventActive']) { IPS_SetEventActive($id, true); } } else { IPS_SetEventTrigger($id, 0, 0); if (IPS_GetEvent($id)['EventActive']) { IPS_SetEventActive($id, false); } } }
protected function SetHidden($Ident, $isHidden) { if (IPS_GetObject($this->GetIDForIdent($Ident))['ObjectIsHidden'] != $isHidden) { IPS_SetHidden($this->GetIDForIdent($Ident), $isHidden); } }
protected function RegisterTimer($Name, $Interval, $Script) { $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID); if ($id === false) { $id = IPS_CreateEvent(1); IPS_SetParent($id, $this->InstanceID); IPS_SetIdent($id, $Name); } IPS_SetName($id, $Name); IPS_SetHidden($id, true); IPS_SetEventScript($id, $Script); if ($Interval > 0) { IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $Interval); IPS_SetEventActive($id, true); } else { IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, 1); IPS_SetEventActive($id, false); } }
public function SetGroup($groupCoordinator) { if ($this->ReadPropertyBoolean("GroupCoordinator")) { return; } $ip = $this->ReadPropertyString("IPAddress"); $timeout = $this->ReadPropertyString("TimeOut"); if ($timeout && Sys_Ping($ip, $timeout) != true) { throw new Exception("Sonos Box " . $ip . " is not available"); } // get variable of coordinator members to be updated if ($groupCoordinator) { $groupMembersID = @IPS_GetObjectIDByIdent("GroupMembers", $groupCoordinator); $uri = "x-rincon:" . IPS_GetProperty($groupCoordinator, "RINCON"); } else { $groupMembersID = @IPS_GetObjectIDByIdent("GroupMembers", GetValue($this->GetIDForIdent("MemberOfGroup"))); $uri = ""; } // update coordinator members SetValue($this->GetIDForIdent("MemberOfGroup"), $groupCoordinator); if ($groupMembersID) { $currentMembers = explode(",", GetValueString($groupMembersID)); $currentMembers = array_filter($currentMembers, function ($v) { return $v != ""; }); $currentMembers = array_filter($currentMembers, function ($v) { return $v != $this->InstanceID; }); if ($groupCoordinator) { $currentMembers[] = $this->InstanceID; } SetValueString($groupMembersID, implode(",", $currentMembers)); } // Set relevant variables to hidden/unhidden if ($groupCoordinator) { $hidden = true; } else { $hidden = false; } IPS_SetHidden($this->GetIDForIdent("nowPlaying"), $hidden); IPS_SetHidden($this->GetIDForIdent("Radio"), $hidden); IPS_SetHidden($this->GetIDForIdent("Playlist"), $hidden); IPS_SetHidden($this->GetIDForIdent("Status"), $hidden); IPS_SetHidden($this->GetIDForIdent("Sleeptimer"), $hidden); include_once __DIR__ . "/sonosAccess.php"; (new SonosAccess($ip))->SetAVTransportURI($uri); }
/** * 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', 'XS1'); $this->RegisterPropertyInteger('ParentCategory', 0); //parent cat is root $this->RegisterPropertyInteger('UpdateInterval', 600); $this->RegisterPropertyString('Host', 'xs1'); $this->RegisterPropertyBoolean('AutoCreate', true); $this->RegisterPropertyBoolean('Debug', false); $this->RegisterPropertyBoolean('Active', false); //Vars $this->RegisterVariableInteger('LastUpdate', 'Last Update', "UnixTimestamp", -1); IPS_SetHidden($this->GetIDForIdent('LastUpdate'), true); //reinit timer $this->RegisterTimer('Update', 0, $this->module_data["prefix"] . '_UpdateEvent($_IPS[\'TARGET\']);'); if (IPS_GetKernelRunlevel() == self::KR_READY) { if ($this->isActive()) { $this->SetStatus(self::ST_AKTIV); $i = $this->GetUpdateInterval(); $this->SetTimerInterval('Update', $i * 1000); //ms $this->init(); } else { $this->SetStatus(self::ST_INACTIV); $this->SetTimerInterval('Update', 0); } } }
public function Update() { $holiday = $this->GetFeiertag(); if (!IPS_GetObject($this->GetIDForIdent("IsHoliday"))['ObjectIsHidden']) { IPS_SetHidden($this->GetIDForIdent("IsHoliday"), true); } SetValue($this->GetIDForIdent("Holiday"), $holiday); if ($holiday != "Arbeitstag" and $holiday != "Wochenende") { SetValue($this->GetIDForIdent("IsHoliday"), true); } else { SetValue($this->GetIDForIdent("IsHoliday"), false); } }
protected function RegisterTimer($Name, $Interval, $Script) { $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID); if ($id === false) { $id = 0; } if ($id > 0) { if (!IPS_EventExists($id)) { throw new Exception("Ident with name " . $Name . " is used for wrong object type"); } if (IPS_GetEvent($id)['EventType'] != 1) { IPS_DeleteEvent($id); $id = 0; } } if ($id == 0) { $id = IPS_CreateEvent(1); IPS_SetParent($id, $this->InstanceID); IPS_SetIdent($id, $Name); } IPS_SetName($id, $Name); IPS_SetHidden($id, true); IPS_SetEventScript($id, $Script); if ($Interval > 0) { IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $Interval); IPS_SetEventActive($id, true); } else { IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, 1); IPS_SetEventActive($id, false); } }
/** * 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); } } }