function get_DeviceNamesByRoomId($RoomId, $SourceIdx=-1, $SourceDeviceTypes=array(c_Property_Input, c_Property_Switch, c_Property_Output)) {
   	$SourceConf     = get_SourceConfiguration();
   	if ($SourceIdx==-1) {
			$SourceId       = get_ControlIdByRoomId($RoomId, c_Control_Source);
			$SourceIdx      = GetValue($SourceId);
		}
		$SourceConfRoom = $SourceConf[IPS_GetName($RoomId)][$SourceIdx];
		$DeviceNames    = array();
		foreach ($SourceDeviceTypes as $SourceDeviceType) {
			if (array_key_exists($SourceDeviceType, $SourceConfRoom)) {
				$DeviceName = $SourceConfRoom[$SourceDeviceType][c_Property_Device];
				$DeviceNames[$DeviceName] = $DeviceName;
			}
		}
		return $DeviceNames;
	}
	function Entertainment_ReceiveData($CommParams, $MessageType=c_MessageType_Action) {
		if (!Entertainment_Before_ReceiveData($CommParams, $MessageType)) {
		   return true;
		}
	
		$CommProperties = get_CommProperties($CommParams);
		if ($CommProperties !== false) {
		   $CommType   = $CommProperties[c_Property_Comm];
		   $DeviceName = $CommProperties[c_Property_Device];
			IPSLogger_Trc(__File__, 'Received Data "'.implode($CommParams, '.').'" for Device '.$DeviceName);
		   switch ($CommType) {
		      case c_Property_CommPower:
		      case c_Property_CommPower2:
		         Entertainment_SetDevicePower(get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower), c_Value_Toggle, $MessageType);
		      	break;
		      case c_Property_CommPowerOn:
		      case c_Property_CommPowerOn2:
		         Entertainment_SetDevicePower(get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower), true, $MessageType);
		      	break;
		      case c_Property_CommPowerOff:
		      case c_Property_CommPowerOff2:
		         Entertainment_SetDevicePower(get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower), false, $MessageType);
		      	break;
		      case c_Property_CommMute:
		      case c_Property_CommMute2:
		         Entertainment_SetMuting(get_ControlIdByDeviceName($DeviceName, c_Control_Muting), c_Value_Toggle, $MessageType);
		      	break;
		      case c_Property_CommMuteOn:
		      case c_Property_CommMuteOn2:
		         Entertainment_SetMuting(get_ControlIdByDeviceName($DeviceName, c_Control_Muting), true, $MessageType);
		      	break;
		      case c_Property_CommMuteOff:
		      case c_Property_CommMuteOff2:
		         Entertainment_SetMuting(get_ControlIdByDeviceName($DeviceName, c_Control_Muting), false, $MessageType);
		      	break;
		      case c_Property_CommVol:
		      case c_Property_CommVol2:
					Entertainment_SetVolume(get_ControlIdByDeviceName($DeviceName, c_Control_Volume),
					                        (int)$CommProperties[c_Template_Value], $MessageType);
		      	break;
		      case c_Property_CommBal:
		      case c_Property_CommBal2:
					Entertainment_SetBalance(get_ControlIdByDeviceName($DeviceName, c_Control_Balance),
					                        (int)$CommProperties[c_Template_Value], $MessageType);
		      	break;
		      case c_Property_CommTre:
		      case c_Property_CommTre2:
					Entertainment_SetTreble(get_ControlIdByDeviceName($DeviceName, c_Control_Treble),
					                        (int)$CommProperties[c_Template_Value], $MessageType);
		      	break;
		      case c_Property_CommMid:
		      case c_Property_CommMid2:
					Entertainment_SetMiddle(get_ControlIdByDeviceName($DeviceName, c_Control_Middle),
					                        (int)$CommProperties[c_Template_Value], $MessageType);
		      	break;
		      case c_Property_CommBas:
		      case c_Property_CommBas2:
					Entertainment_SetBass(get_ControlIdByDeviceName($DeviceName, c_Control_Bass),
					                        (int)$CommProperties[c_Template_Value], $MessageType);
		      	break;
		      case c_Property_CommMode:
		      case c_Property_CommMode2:
		         Entertainment_SetMode(get_ControlIdByDeviceName($DeviceName, c_Control_Mode),
					                      $CommProperties[c_Template_Value], $MessageType);
		      	break;
		      case c_Property_CommRemSrc:
			      $ControlId = get_ControlIdByDeviceName($DeviceName, c_Control_RemoteSourceType);
			      $Value = $CommProperties[c_Template_Value];
		         Entertainment_SetRemoteControlType($ControlId,
					                                   $Value,
					                                   c_Control_RemoteSource);
		      	break;
		      case c_Property_CommRemVol:
		         Entertainment_SetRemoteControlType(get_ControlIdByDeviceName($DeviceName, c_Control_RemoteVolumeType),
					                                   $CommProperties[c_Template_Value],
																  c_Control_RemoteVolume);
		      	break;
		      case c_Property_CommSrc:
		      case c_Property_CommSrc2:
				   $SourceIdx  = $CommProperties[c_Property_SourceIdx];
				   $RoomName   = $CommProperties[c_Property_Room];
				   IPSLogger_Inf(__file__, "Switch Source for $RoomName to $SourceIdx");
		         Entertainment_SetSource(get_ControlIdByRoomId(get_RoomId($RoomName), c_Control_Source), $SourceIdx, $MessageType);
		      	break;
		      case c_Property_CommPrg:
		      case c_Property_CommPrg2:
		         Entertainment_SetProgram(get_ControlIdByDeviceName($DeviceName, c_Control_Program),
					                         $CommProperties[c_Template_Value], $MessageType);
		      	break;
		      case c_Property_CommPrgPrev:
		      case c_Property_CommPrgPrev2:
		         Entertainment_SetProgramPrev(get_ControlIdByDeviceName($DeviceName, c_Control_Program), $MessageType);
		      	break;
		      case c_Property_CommPrgNext:
		      case c_Property_CommPrgNext2:
		         Entertainment_SetProgramNext(get_ControlIdByDeviceName($DeviceName, c_Control_Program), $MessageType);
		      	break;
		      default:
					IPSLogger_Err(__File__, 'Found unknown CommunicationType "'.$CommType.'"');
		   }
		   Entertainment_After_ReceiveData($CommParams, $MessageType);
			return true;
		}
	   Entertainment_After_ReceiveData($CommParams, $MessageType);
		return false;
	}
<?
	/**@ingroup entertainment 
	 * @{
	 *
	 * @file          Entertainment_PostInstallation.ips.php
	 * @author        Andreas Brauneis
	 * @version
	 *  Version 2.50.1, 31.01.2012<br/>
	 *
	 * Dieses Script wird nach jeder Installation der Entertainment Steuerung ausgeführt und
	 * führt einige kleinere Nacharbeiten aus.
	 */

	//Sync Devices to Roomes
	echo "--- Default Settings -------------------------------------------------------------------\n";
	IPSUtils_Include ("Entertainment.inc.php", "IPSLibrary::app::modules::Entertainment");

	Entertainment_SyncAllRoomControls();

	$RoomIds = IPS_GetChildrenIDs(c_ID_Roomes);
	foreach ($RoomIds as $RoomId) {
		$RoomPowerId = get_ControlIdByRoomId($RoomId, c_Control_RoomPower);
		Entertainment_SetRoomVisible($RoomPowerId, GetValue($RoomPowerId));
	}

	/** @}*/
?>
Exemplo n.º 4
0
	function IsRoomPoweredOn($RoomId) {
	   $PowerId = get_ControlIdByRoomId($RoomId, c_Control_RoomPower);
	   return GetValue($PowerId);
	}
	function Entertainment_SetSourceByRoomId($RoomId, $SourceIdx) {
	   $SourceId = get_ControlIdByRoomId($RoomId, c_Control_Source);
		Entertainment_SetSource($SourceId, $SourceIdx);
	}
	function Entertainment_SetDeviceControlByRoomId($RoomId, $ControlType, $Value) {
		$RoomControlId = get_ControlIdByRoomId($RoomId, $ControlType);
		if ($RoomControlId !== false) {
		   Entertainment_SetDeviceControlByRoomControlId($RoomControlId, $Value);
		}
	}