コード例 #1
0
	function Entertainment_Before_SendData($Parameters) {
		if ($Parameters[0]==c_Comm_WinLIRC and $Parameters[1]=='yamahareceiver') {
			$Button      = $Parameters[2];

			// Special Handling for Muting of YamahaReceiver: Use InputSelector Phone for Muting,
			// Switch back to current Input when Muting Off
			// ==================================================================================
			if ($Button == "muteon") {
				IPSLogger_Dbg(__file__, "Set Muting 'On' for Yamaha Receiver (Switch to Phone Input)");
            WinLIRC_SendData(array(c_Comm_WinLIRC, 'yamahareceiver', 'phone'));
				return false; // Abort current Processing

			} else if ($Button=='muteoff') {
				$RoomId = get_RoomId(c_Room_LivingRoom);
				$SourceIdx = get_SourceIdxByRoomId($RoomId);
		   	Entertainment_SendDataBySourceIdx($RoomId, $SourceIdx, c_MessageType_Action);
				return false; // Abort current Processing

		   // Special Handling for Yamaha Tuner, YamahaReceiver supports only Previous/Next Station for Tuner
		   // --> Simulate Buttons for Station "1" - "8" by Previous and Next.
	   	// ===============================================================================================
			} else if ($Button == "0" or $Button == "1" or $Button == "2" or $Button == "3" or $Button == "4" or
			           $Button == "5" or $Button == "6" or $Button == "7") {
				$ControlId   = get_ControlIdByDeviceName(c_Device_YamahaTuner, c_Control_Program);
				$StationNew  = GetValue($ControlId);
				$StationObj  = IPS_GetObject($ControlId);
				$StationCurr = $StationObj["ObjectInfo"];
				IPSLogger_Trc(__file__, "Switch YamahaTuner from StationCurrent=".$StationCurr." to  StationNew=".$StationNew);

				if ($StationNew-$StationCurr <= 4 and $StationNew-$StationCurr >= 0) {
				   $IRButton = 'presetnext';
					$Count = $StationNew-$StationCurr;
				} else if (($StationCurr-$StationNew) < 0) {
				   $IRButton = 'presetlast';
					$Count = 8-($StationNew-$StationCurr);
				} else if (($StationCurr-$StationNew) <= 4) {
				   $IRButton = 'presetlast';
					$Count = $StationCurr-$StationNew;
				} else {
				   $IRButton = 'presetnext';
					$Count = 8-$StationCurr+$StationNew;
				}

				IPS_SetInfo ($ControlId, $StationNew);
				IPSLogger_Dbg(__file__, "Switch Yamaha TunerStation from ".$StationCurr." to ".$StationNew." ==> ".$Count."x ".$IRButton);
				for ($idx=1; $idx<=$Count; $idx++) {
					include_once "Entertainment_InterfaceWinLIRC.ips.php";
               WinLIRC_SendData(array(c_Comm_WinLIRC, 'yamahareceiver', $IRButton));
					sleep(0.2);
				}
				return false; // Abort current Processing
			}
		}
		return true;
	}
コード例 #2
0
	function Entertainment_SetDevicePowerByDeviceName($DeviceName, $Value, $MessageType=c_MessageType_Action) {
		IPSLogger_Trc(__file__, 'Handle Device Power for "'.$DeviceName.'" '.bool2OnOff($Value));
		$PowerId = get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower, false);
		if ($PowerId!==false) {
		   if (!is_bool($Value)) { 												/*Toggle Power Value*/
      		$Value = !GetValue($PowerId);
				IPSLogger_Dbg(__file__, "Toogle Device Power for '$DeviceName' to ".bool2OnOff($Value));
   		}
			if (GetValue($PowerId) <> $Value) {
				IPSLogger_Inf(__file__, 'Set Device Power for "'.$DeviceName.'" '.bool2OnOff($Value));
				if ($Value) {
					Entertainment_SendDataByDeviceName($DeviceName, c_Control_DevicePower,
																	array(c_Property_CommPowerOn, c_Property_CommPower), $MessageType);
				} else {
					Entertainment_SendDataByDeviceName($DeviceName, c_Control_DevicePower,
																	array(c_Property_CommPowerOff, c_Property_CommPower), $MessageType);
				}
				SetValue($PowerId, $Value);
				Entertainment_Connect($DeviceName, $Value, true);
				Entertainment_SetDeviceControlByDeviceName($DeviceName, c_Control_Muting, false);
		      Entertainment_SetRoomPowerByDeviceName($DeviceName, $Value);
			}
		}
	}
コード例 #3
0
	function get_DeviceControlIdByRoomControlId($RoomControlId, $ControlType=null) {
	   $RoomId = IPS_GetParent($RoomControlId);
		$DeviceNames = get_DeviceNamesByRoomId($RoomId);
		
		if ($ControlType==null) {
			$ControlType = get_ControlType($RoomControlId);
		}
		if ($ControlType == c_Control_Volume or $ControlType == c_Control_Muting or $ControlType == c_Control_RemoteVolume) {
		   $DeviceNames = array_reverse($DeviceNames);
		}
		foreach($DeviceNames as $DeviceName) {
			$DeviceControlId = get_ControlIdByDeviceName($DeviceName, $ControlType, false);
			if ($DeviceControlId !== false) {
			   return $DeviceControlId;
			}
		}
		return false;
	}
コード例 #4
0
	function Entertainment_SendData($DeviceName, $ControlType, $CommParams, $CommType) {
      $CommConfig     = get_CommunicationConfiguration();
      $CommInterface  = $CommParams[0];
		$FunctionName   = $CommConfig[$CommInterface][c_Property_FunctionSnd];
		$FunctionScript = $CommConfig[$CommInterface][c_Property_ScriptSnd];
		$FunctionParameters = array();
		foreach ($CommParams as $CommIdx=>$CommParam) {
		   if ($CommParam==c_Template_Value) {
			   $FunctionParameters[] = GetValue(get_ControlIdByDeviceName($DeviceName, $ControlType));
		   } else if ($CommParam==c_Template_Code) {
		      $DeviceConfig = get_DeviceConfiguration();
		      $Value = GetValue(get_ControlIdByDeviceName($DeviceName, $ControlType));
			   $FunctionParameters[] = $DeviceConfig[$DeviceName][$ControlType][c_Property_Codes][$Value];
			} else {
			   $FunctionParameters[] = $CommParam;
			}
		}
		if (!Entertainment_Before_SendData($FunctionParameters)) {
		   return;
		}
	   IPSLogger_Trc(__file__, 'SendData '.$CommInterface.'.'.$FunctionName.'('.implode(',',$FunctionParameters).')');
		try {
			include_once $FunctionScript;
			$Function       = new ReflectionFunction($FunctionName);
			$Function->invoke($FunctionParameters);
		} catch (Exception $e) {
	     	IPSLogger_Err(__file__, 'Error Executing Function '.$FunctionName.':'.$e->getMessage());
		}
  		Entertainment_After_SendData($FunctionParameters);
	}
コード例 #5
0
	function WinLIRC_ReceiveData_Program($Program, $DeviceName) {
     	IPSLogger_Com(__file__, "Received Program '$Program' from WinLIRC-Webfront, Device='$DeviceName'");
     	$ControlId = get_ControlIdByDeviceName($DeviceName, c_Control_Program);
     	if ($Program=='next') {
	     	Entertainment_SetProgramNext($ControlId);
     	} else if ($Program=='prev') {
	     	Entertainment_SetProgramPrev($ControlId);
     	} else {
	     	Entertainment_SetProgram($ControlId, $Program);
     	}
     	return GetValue($ControlId);
	}
コード例 #6
0
	function	Entertainment_RefreshRemoteControlByDeviceName($DeviceName, $ControlType=c_Control_RemoteSource) {
		$RemoteControlId = get_ControlIdByDeviceName($DeviceName, $ControlType, false);
		if ($RemoteControlId !== false) {
		   Entertainment_SetRemoteControl($RemoteControlId, GetValue($RemoteControlId));
		}
	}
コード例 #7
0
	function Entertainment_SetDeviceControlByDeviceName($DeviceName, $ControlType, $Value) {
		$DeviceControlId = get_ControlIdByDeviceName($DeviceName, $ControlType, false);
		if ($DeviceControlId !== false) {
			Entertainment_SetDeviceControl($DeviceControlId, $Value);
		}
	}
コード例 #8
0
	
	IPS_SemaphoreEnter('NetPlayer', 1000);

	if($IPS_SENDER == "Variable") {
	   $variableName = IPS_GetName($IPS_VARIABLE);
		switch ($variableName) {
		   case 'Power':
		      if ($IPS_VALUE) {
					Entertainment_ReceiveData(array(c_Comm_NetPlayer, 'netplayer', 'poweron'), c_MessageType_Info);
				} else {
					Entertainment_ReceiveData(array(c_Comm_NetPlayer, 'netplayer', 'poweroff'), c_MessageType_Info);
				}
		   	break;
		   case 'RemoteControl':
		      $ControlId = get_ControlIdByDeviceName(c_Device_NetPlayer, c_Control_RemoteSourceType);
		   	if (GetValue(NP_ID_CONTROLTYPE) <> GetValue($ControlId)) {
		      	IPSLogger_Com(__file__, "Receive RemoteControlType ".GetValue(NP_ID_CONTROLTYPE)." for NetPlayer");
					Entertainment_ReceiveData(array(c_Comm_NetPlayer, 'netplayertype', (string)GetValue(NP_ID_CONTROLTYPE)), c_MessageType_Info);
				} else {
		      	Entertainment_RefreshRemoteControlByDeviceName(c_Device_NetPlayer);
				}
		   	break;
		   case 'MobileControl':
		      //Entertainment_RefreshRemoteControlByDeviceName(c_Device_NetPlayer, c_Control_iRemoteSource);
		   	break;
		   case 'ControlType':
		      //IPSLogger_Com(__file__, "Receive RemoteControlType $IPS_VALUE for NetPlayer");
				//Entertainment_ReceiveData(array(c_Comm_NetPlayer, 'netplayertype', (string)$IPS_VALUE), c_MessageType_Info);
		   	break;
		   default: