function get_MaxValueByControlId($ControlId) {
		$VariableObject = IPS_GetVariable($ControlId);
		$ProfileName = $VariableObject['VariableCustomProfile'];
		$ProfileObject = IPS_GetVariableProfile($ProfileName);
		$MaxValue = Count($ProfileObject['Associations']);
		return $MaxValue;
	}
示例#2
0
 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);
 }
示例#3
0
	function NetPlayer_RefreshTrackListValue() {
		$currentIdx    = -1;
		$player = NetPlayer_GetIPSComponentPlayer();
		$currentName   = $player->GetTrackName();
		$currentName   = NetPlayer_GetTrackName($currentName);
		$currentName   = str_replace(GetValue(NP_ID_CDINTERPRET).' - ', '', $currentName);

		$profileData   = IPS_GetVariableProfile('NetPlayer_CDTrackList');
		$associations  = $profileData['Associations'];
		foreach ($associations as $idx=>$data) {
			IPSLogger_Trc(__file__, "Idx=$idx, '$currentName' --> '".$data['Name']."'");
			if ($currentName == $data['Name']) {
			   $currentIdx = $data['Value'];
			}
		}
		if (GetValue(NP_ID_CDTRACKLIST)<>$currentIdx ) {
		   SetValue(NP_ID_CDTRACKLIST, $currentIdx);
		}
	}
	function NetPlayer_GetNameFromProfile($value, $name) {
      $profileData   = IPS_GetVariableProfile($name);
		$associations  = $profileData['Associations'];
		foreach ($associations as $idx=>$association) {
		   if ($association['Value']==$value) {
		      $name = $association['Name'];
		   }
		}
		return $name;
	}
示例#5
0
	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]);
		}
	}
示例#6
0
 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);
 }
示例#7
0
 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];
     }
     $this->RegisterProfileInteger($Name, $Icon, $Prefix, $Suffix, $MinValue, $MaxValue, 0);
     $old = IPS_GetVariableProfile($Name)["Associations"];
     $OldValues = array_column($old, 'Value');
     foreach ($Associations as $Association) {
         IPS_SetVariableProfileAssociation($Name, $Association[0], $Association[1], $Association[2], $Association[3]);
         $OldKey = array_search($Association[0], $OldValues);
         if (!($OldKey === false)) {
             unset($OldValues[$OldKey]);
         }
     }
     foreach ($OldValues as $OldKey => $OldValue) {
         IPS_SetVariableProfileAssociation($Name, $OldValue, '', '', 0);
     }
 }
示例#8
0
 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);
 }
示例#9
0
 protected function RegisterProfileBoolean($Name, $Icon)
 {
     if (!IPS_VariableProfileExists($Name)) {
         IPS_CreateVariableProfile($Name, 0);
     } else {
         $profile = IPS_GetVariableProfile($Name);
         if ($profile['ProfileType'] != 0) {
             throw new Exception("Variable profile type does not match for profile " . $Name);
         }
     }
     IPS_SetVariableProfileIcon($Name, $Icon);
     IPS_SetVariableProfileAssociation("{$Name}", 1, "Lueften erlaubt", "", 0xff00);
     IPS_SetVariableProfileAssociation("{$Name}", 0, "Lueften verboten", "", 0xff0000);
 }
示例#10
0
 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();
     }
 }
示例#11
0
     $playingRadioStation = '';
     foreach ($radioStations as $radioStation) {
         if ($radioStation["url"] == htmlspecialchars_decode($mediaInfo["CurrentURI"])) {
             $playingRadioStation = $radioStation["name"];
             break;
         }
     }
     if ($playingRadioStation == '') {
         foreach ((new SimpleXMLElement($sonos->BrowseContentDirectory('R:0/0')['Result']))->item as $item) {
             if ($item->res == htmlspecialchars_decode($mediaInfo["CurrentURI"])) {
                 $playingRadioStation = (string) $item->xpath('dc:title')[0];
                 break;
             }
         }
     }
     $Associations = IPS_GetVariableProfile("Radio.SONOS")["Associations"];
     if (isset($playingRadioStation)) {
         foreach ($Associations as $key => $station) {
             if ($station["Name"] == $playingRadioStation) {
                 $currentStation = $station["Value"];
                 break;
             }
         }
     }
     // end find current Radio in VariableProfile
 }
 SetValueInteger(IPS_GetObjectIDByName("Radio", IPS_GetParent($_IPS["SELF"])), $currentStation);
 // Sleeptimer
 if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "SleeptimerControl")) {
     $sleeptimer = $sonos->GetSleeptimer();
     if ($sleeptimer) {
示例#12
0
		private function ReceiveCodeVariable($object) {
			$variableId   = (int)$object['Id'];
			$variable     = IPS_GetVariable($variableId);
			$value        = GetValue($variableId);
			$action       = $variable['VariableCustomAction'] ;
			$type         = $variable['VariableValue']['ValueType'];
			$profile      = $variable['VariableCustomProfile'];
			$profileData  = IPS_GetVariableProfile($profile);
			$associations = $profileData['Associations'];

			if ($profile=='' or $action==0) return;

			if (GetValue($this->objectEditId)<>0) {
				SetValue($this->objectEditId, 0);
			}

			switch($type) {
				case 0: // Boolean
					IPSLogger_Dbg(__file__, 'Execute Action '.$action);
					IPS_RunScriptWaitEx($action, array( 'SENDER'=>'WebFront', 'VALUE'=>!$value, 'VARIABLE'=>$variableId, 'REMOTE_ADDR'=>'localhost'));
					break;
				case 1: // Integer
					if ($object['Value']=="") {
						SetValue($this->objectEditId, $variableId);
					} else {
						IPS_RunScriptWaitEx($action, array( 'SENDER'=>'WebFront', 'VALUE'=>(int)$object['Value'], 'VARIABLE'=>$variableId, 'REMOTE_ADDR'=>'localhost'));
					}
					break;
				case 2: // Float
					break;
				case 3: // String
					break;
				default: // Unsupported Datatype
			}
		}