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; }
function get_SourceListByDeviceName($DeviceName) { $SourceConfig = get_SourceConfiguration(); $SourceList = array(); foreach ($SourceConfig as $RoomName=>$RoomSources) { $RoomId = get_RoomId($RoomName); $CurrentIdx = get_SourceIdxByRoomId($RoomId); foreach ($RoomSources as $SourceIdx=>$SourceData) { $DeviceNames = get_DeviceNamesByRoomId($RoomId, $SourceIdx, array(c_Property_Output)); if (in_array($DeviceName, $DeviceNames)) { if (!array_key_exists($RoomId, $SourceList)) { $SourceList[$RoomId] = $SourceIdx; } if ($CurrentIdx==$SourceIdx) { $SourceList[$RoomId] = $SourceIdx; break; } } } } return $SourceList; }
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; }