/** * OWLan_Update(); */ public function Update() { if ($this->ReadPropertyInteger("DeviceType") === 0) { $URL = "http://" . $this->ReadPropertyString("IPAddress") . ":" . $this->ReadPropertyInteger("Port") . "/details.xml"; if (!Sys_Ping($this->ReadPropertyString("IPAddress"), 1000)) { $this->SetStatus(201); trigger_error("Invalid IP-Address", E_USER_ERROR); exit; } try { $xml = @new SimpleXMLElement($URL, NULL, TRUE); } catch (Exception $ex) { $this->SetStatus(200); trigger_error("OneWireLan: " . $ex->getMessage() . "!", E_USER_ERROR); exit; } $this->SetValue($this->RegisterVariableInteger("PollCount", "PollCount", "", -5), (int) $xml->PollCount); $this->SetValue($this->RegisterVariableFloat("VoltagePower", "VoltagePower", "~Volt", -4), (double) $xml->VoltagePower); $this->SetValue($this->RegisterVariableInteger("DevicesConnectedChannel1", "DevicesConnectedChannel1", "", -3), (int) $xml->DevicesConnectedChannel1); $this->SetValue($this->RegisterVariableByParent($this->GetIDForIdent("DevicesConnectedChannel1"), "DataErrorsChannel1", "DataErrorsChannel1", 1), (int) $xml->DataErrorsChannel1); $this->SetValue($this->RegisterVariableByParent($this->GetIDForIdent("DevicesConnectedChannel1"), "VoltageChannel1", "VoltageChannel1", 2, "~Volt"), (double) $xml->VoltageChannel1); $this->SetValue($this->RegisterVariableInteger("DevicesConnectedChannel2", "DevicesConnectedChannel2", "", -2), (int) $xml->DevicesConnectedChannel2); $this->SetValue($this->RegisterVariableByParent($this->GetIDForIdent("DevicesConnectedChannel2"), "DataErrorsChannel2", "DataErrorsChannel2", 1), (int) $xml->DataErrorsChannel2); $this->SetValue($this->RegisterVariableByParent($this->GetIDForIdent("DevicesConnectedChannel2"), "VoltageChannel2", "VoltageChannel2", 2, "~Volt"), (double) $xml->VoltageChannel2); $this->SetValue($this->RegisterVariableInteger("DevicesConnectedChannel3", "DevicesConnectedChannel3", "", -1), (int) $xml->DevicesConnectedChannel3); $this->SetValue($this->RegisterVariableByParent($this->GetIDForIdent("DevicesConnectedChannel3"), "DataErrorsChannel3", "DataErrorsChannel3", 1), (int) $xml->DataErrorsChannel3); $this->SetValue($this->RegisterVariableByParent($this->GetIDForIdent("DevicesConnectedChannel3"), "VoltageChannel3", "VoltageChannel3", 2, "~Volt"), (double) $xml->VoltageChannel3); $data = array(); $this->ROMIds = array(); foreach ($xml->owd_DS18B20 as $Sensor) { $ROMId = (string) $Sensor->ROMId; $this->ROMIds["DS18B20"][$ROMId] = ""; $data["owd_DS18B20"][$ROMId]["Health"] = (int) $Sensor->Health; $data["owd_DS18B20"][$ROMId]["Temperature"] = (double) $Sensor->Temperature; } foreach ($xml->owd_DS18S20 as $Sensor) { $ROMId = (string) $Sensor->ROMId; $this->ROMIds["DS18S20"][$ROMId] = ""; $data["owd_DS18S20"][$ROMId]["Health"] = (int) $Sensor->Health; $data["owd_DS18S20"][$ROMId]["Temperature"] = (double) $Sensor->Temperature; } foreach ($xml->owd_DS2438 as $Sensor) { $ROMId = (string) $Sensor->ROMId; $this->ROMIds["DS2438"][$ROMId] = ""; $data["owd_DS2438"][$ROMId]["Health"] = (int) $Sensor->Health; $data["owd_DS2438"][$ROMId]["Temperature"] = (double) $Sensor->Temperature; $data["owd_DS2438"][$ROMId]["Vdd"] = (double) $Sensor->Vdd; $data["owd_DS2438"][$ROMId]["Vad"] = (double) $Sensor->Vad; $data["owd_DS2438"][$ROMId]["Vsense"] = (double) $Sensor->Vsense; } $this->SendDataToChildren(json_encode(array("DataID" => "{B62FA047-5739-4518-A30B-2B12339713A2}", "Buffer" => json_encode($data)))); $this->SetStatus(102); } }
protected function GetOnlineState() { if (!is_null($this->_boIsOnline)) { return $this->_boIsOnline; } if (!($host = $this->ReadPropertyString("Host"))) { throw new Exception("No Hostname"); } if ($test = @parse_url($host)['host']) { $host = $test; } $this->_boIsOnline = Sys_Ping($host, 2000); $this->SetValueBoolean('OnlineStateVAR', $this->_boIsOnline); return $this->_boIsOnline; }
* Dieses Script aktualisiert die Wetterdaten in IPS * * @file IPSWeatherForcastAT_Refresh.ips.php * @author Andreas Brauneis * @version * Version 2.50.1, 15.02.2012<br/> * */ IPSUtils_Include ("IPSWeatherForcastAT_Constants.inc.php", "IPSLibrary::app::modules::Weather::IPSWeatherForcastAT"); IPSUtils_Include ("IPSWeatherForcastAT_Configuration.inc.php", "IPSLibrary::config::modules::Weather::IPSWeatherForcastAT"); IPSUtils_Include ("IPSWeatherForcastAT_Utils.inc.php", "IPSLibrary::app::modules::Weather::IPSWeatherForcastAT"); IPSUtils_Include ("IPSLogger.inc.php", "IPSLibrary::app::core::IPSLogger"); if (Sys_Ping(IPSWEATHERFAT_EXTERNAL_IP, 100)) { IPSLogger_Trc(__file__, "Refresh Weather Data"); $stationGoogle = IPSWEATHERFAT_GOOGLE_PLACE."-".IPSWEATHERFAT_GOOGLE_COUNTRY; $urlGoogle = "http://www.google.com/ig/api?weather=".$stationGoogle."&hl=".IPSWEATHERFAT_GOOGLE_LANG; $DaySourceArray = array('Mo.','Di.','Mi.','Do.','Fr.','Sa.','So.'); $DayDisplayArray = array('Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'); $api = simplexml_load_string(utf8_encode(@Sys_GetURLContent($urlGoogle))); echo $urlGoogle; IPSWeatherFAT_SetValue('LastRefreshDateTime', date("Y-m-j H:i:s")); IPSWeatherFAT_SetValue('LastRefreshTime', date("H:i")); // Aktuelles Wetter IPSWeatherFAT_SetValue('TodayForecastShort', (string)$api->weather->current_conditions->condition->attributes()->data);
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); } }
public function GetPowerState() { $IP = $this->ReadPropertyString("Enigma2IP"); $WebPort = $this->ReadPropertyInteger("Enigma2WebPort"); if (@Sys_Ping($IP, 2000) == false and $this->ReadPropertyString("Enigma2IP") != "") { $PowerStateIST = 0; $this->SetValueInteger("PowerStateVAR", 0); // AUS } else { $url = "http://" . $IP . ":" . $WebPort . "/web/powerstate"; $xml = @simplexml_load_file($url); if ($this->ResultAuswerten(@$xml->e2instandby) == "false" or trim(@$xml->e2instandby) == "false") { $PowerStateIST = 1; $this->SetValueInteger("PowerStateVAR", 1); // AN } else { $PowerStateIST = 2; $this->SetValueInteger("PowerStateVAR", 2); // STANDBY } } return $PowerStateIST; }
public function UpdateRadioStations() { include_once __DIR__ . "/radio_stations.php"; $Associations = array(); $AvailableStations = get_available_stations(); $WebFrontStations = $this->ReadPropertyString("WebFrontStations"); $WebFrontStationsArray = array_map("trim", explode(",", $WebFrontStations)); $FavoriteStation = $this->ReadPropertyString("FavoriteStation"); $Value = 1; foreach ($AvailableStations as $key => $val) { if (in_array($val['name'], $WebFrontStationsArray) || $WebFrontStations === "<alle>" || $WebFrontStations === "<all>") { if ($val['name'] === $FavoriteStation) { $Color = 0xfcec00; } else { $Color = -1; } $Associations[] = array($Value++, $val['name'], "", $Color); // associations only support up to 32 variables if ($Value === 33) { break; } } } if ($this->ReadPropertyString("IncludeTunein") && $Value < 33) { $ip = $this->ReadPropertyString("IPAddress"); $timeout = $this->ReadPropertyString("TimeOut"); if ($timeout && Sys_Ping($ip, $timeout) != true) { throw new Exception("Sonos Box " . $ip . " is not available"); } include_once __DIR__ . "/sonosAccess.php"; $sonos = new SonosAccess($ip); foreach ((new SimpleXMLElement($sonos->BrowseContentDirectory('R:0/0')['Result']))->item as $item) { $Associations[] = array($Value++, (string) $item->xpath('dc:title')[0], "", 0x539de1); // associations only support up to 32 variables if ($Value === 33) { break; } } } usort($Associations, function ($a, $b) { return strnatcmp($a[1], $b[1]); }); $Value = 1; foreach ($Associations as $Association) { $Associations[$Value - 1][0] = $Value++; } if (IPS_VariableProfileExists("Radio.SONOS")) { IPS_DeleteVariableProfile("Radio.SONOS"); } $this->RegisterProfileIntegerEx("Radio.SONOS", "Speaker", "", "", $Associations); }
/** * WriteSingleRegister * @param integer $UnitId * @param integer $Reference * @param integer $Data */ protected function WriteSingleRegister($UnitId, $Reference, $Data) { include_once __DIR__ . "/lib/ModbusMaster.php"; $URL = "http://" . $this->ReadPropertyString("IPAddress"); //$headers = @get_headers($URL); if (!Sys_Ping($this->ReadPropertyString("IPAddress"), 1000)) { $this->SetStatus(201); trigger_error("Invalid IP-Address", E_USER_ERROR); exit; } $this->SetStatus(102); if ($this->ReadPropertyInteger("GatewayMode") === 0) { $modbus = new ModbusMasterTcp($this->ReadPropertyString("IPAddress")); } else { $modbus = new ModbusMasterUdp($this->ReadPropertyString("IPAddress")); } //FC 6 try { if (IPS_SemaphoreEnter("ModbusMaster", 1000)) { $this->Log("WriteSingleRegister({$UnitId}|{$Reference}|{$Data})"); $modbus->writeSingleRegister($UnitId, $Reference, array($Data), array("INT")); IPS_SemaphoreLeave("ModbusMaster"); } } catch (Exception $e) { $this->SetStatus(200); trigger_error("ModbusMaster: " . $e->getMessage() . "!", E_USER_ERROR); exit; } }
public function setRadio() { // reset values SetValue($this->GetIDForIdent("DeviceMode"), ""); SetValue($this->GetIDForIdent("DeviceState"), ""); SetValue($this->GetIDForIdent("NowPlaying"), ""); SetValue($this->GetIDForIdent("Description"), ""); SetValue($this->GetIDForIdent("Logo"), ""); // get radio $instanceid = IPS_GetInstance($this->InstanceID)['InstanceID']; $stationname = GetValueFormatted($this->GetIDForIdent("Radio")); $associations = IPS_GetVariableProfile("bose.Device" . $instanceid . "RadioStations")["Associations"]; foreach ($associations as $key => $value) { if ($value["Name"] == $stationname) { $index = $value["Value"]; } } $associations = IPS_GetVariableProfile("bose.Device" . $instanceid . "RadioLocations")["Associations"]; foreach ($associations as $key => $value) { if ($value["Value"] == $index) { $location = $value["Name"]; } } // set location $timeout = $this->ReadPropertyString("Timeout"); $deviceip = $this->ReadPropertyString("DeviceIP"); try { if ($timeout && Sys_Ping($deviceip, $timeout) != true) { throw new Exception("Device " . $deviceip . " is not available"); } include_once __DIR__ . "/bose_soundtouch_api.php"; $bosedevice = new BoseSoundTouchAPI($deviceip); $result = $bosedevice->setDeviceRadioStationAPI($location); // get now playing ??? SetValue($this->GetIDForIdent("DevicePower"), true); } catch (Exception $e) { echo $e->getMessage(); } }
function Sys_Ping() { $p = parse_url($this->_url); $host = empty($p['host']) ? $this->_url : $p['host']; return Sys_Ping($host, 2000); }
public function Update() { $Hostname = $this->ReadPropertyString("HostName"); $Hostadresse = $this->ReadPropertyString("HostAdresse"); $PingTimeout = $this->ReadPropertyInteger("PingTimeout"); if ($Hostname != "" and $Hostadresse != "") { $result = @Sys_Ping($Hostadresse, $PingTimeout); $HostLastOnlineTime = time(); if ($result === true) { // OK-Benachrichtung senden, wenn vorher Offline-Benachrichtung gesendet wurde > wenn Einstellung aktiv if (GetValueBoolean($this->GetIDForIdent("HostBenachrichtigungsFlag")) === true and $this->ReadPropertyBoolean("OnlineBenachrichtigung") === true) { $this->Benachrichtigung(true, true); } $this->SetValueBoolean("HostBenachrichtigungsFlag", false); $this->SetTimerByIdent_InSekunden("HMON_BenachrichtigungOfflineTimer", false); $this->SetValueBoolean("HostStatus", $result); $this->SetValueInteger("HostLastOnline", $HostLastOnlineTime); } else { if (GetValueBoolean($this->GetIDForIdent("HostBenachrichtigungsFlag")) === false and $this->ReadPropertyBoolean("OfflineBenachrichtigung") === true) { $BenachrichtigungsTimer = $this->ReadPropertyInteger("AlarmZeitDiff"); if ($BenachrichtigungsTimer == 0) { $this->Benachrichtigung(false, true); } if (GetValueBoolean($this->GetIDForIdent("HostStatus")) === true) { $this->SetTimerByIdent_InSekunden("HMON_BenachrichtigungOfflineTimer", $BenachrichtigungsTimer); } } $this->SetValueBoolean("HostStatus", $result); } } }
<?php include_once "../modules/SymconSonos/Sonos/sonosAccess.php"; include_once "../modules/SymconSonos/Sonos/radio_stations.php"; $ip = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "IPAddress"); $timeout = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "TimeOut"); if (!$timeout || Sys_Ping($ip, $timeout) == true) { $sonos = new SonosAccess($ip); $status = $sonos->GetTransportInfo(); SetValueInteger(IPS_GetObjectIDByName("Volume", IPS_GetParent($_IPS["SELF"])), $sonos->GetVolume()); if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "MuteControl")) { SetValueInteger(IPS_GetObjectIDByName("Mute", IPS_GetParent($_IPS["SELF"])), $sonos->GetMute()); } if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "LoudnessControl")) { SetValueInteger(IPS_GetObjectIDByName("Loudness", IPS_GetParent($_IPS["SELF"])), $sonos->GetLoudness()); } if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "BassControl")) { SetValueInteger(IPS_GetObjectIDByName("Bass", IPS_GetParent($_IPS["SELF"])), $sonos->GetBass()); } if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "TrebleControl")) { SetValueInteger(IPS_GetObjectIDByName("Treble", IPS_GetParent($_IPS["SELF"])), $sonos->GetTreble()); } if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "BalanceControl")) { $leftVolume = $sonos->GetVolume("LF"); $rightVolume = $sonos->GetVolume("RF"); if ($leftVolume == $rightVolume) { SetValueInteger(IPS_GetObjectIDByName("Balance", IPS_GetParent($_IPS["SELF"])), 0); } elseif ($leftVolume > $rightVolume) { SetValueInteger(IPS_GetObjectIDByName("Balance", IPS_GetParent($_IPS["SELF"])), $rightVolume - 100); } else { SetValueInteger(IPS_GetObjectIDByName("Balance", IPS_GetParent($_IPS["SELF"])), 100 - $leftVolume);
continue; } $xmlr = new SimpleXMLElement($result); $rincon = str_replace("uuid:", "", $xmlr->device->UDN); IPS_SetProperty($SonosID, "RINCON", $rincon); IPS_ApplyChanges($SonosID); } } $rinconMapping[] = array("ID" => $SonosID, "RINCON" => $rincon); if ($SonosID === IPS_GetParent($_IPS["SELF"])) { $ownRincon = $rincon; } } $ipAddress = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "IPAddress"); $timeout = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "TimeOut"); if (!$timeout || Sys_Ping($ipAddress, $timeout) == true) { $sonos = new SonosAccess($ipAddress); $sonosGroupCoordinator = explode(":", $sonos->GetZoneGroupAttributes()["CurrentZoneGroupID"])[0]; foreach ($rinconMapping as $key => $value) { if ($value["RINCON"] === $sonosGroupCoordinator) { $sonosGroupCoordinatorID = $value["ID"]; break; } } // If groupCoordinator in Sonos = this instance --> set ID to 0 (does not belong to group) if ($sonosGroupCoordinatorID === IPS_GetParent($_IPS["SELF"])) { $sonosGroupCoordinatorID = 0; } if ($sonosGroupCoordinatorID !== $MemberOfGroup) { if ($groupForcing) { SNS_SetGroup(IPS_GetParent($_IPS["SELF"]), $MemberOfGroup);