function Entertainment_SetDevicePowerByRoomId($RoomId, $Value=true) { if ($Value) { $RoomName = IPS_GetName($RoomId); $DeviceNames = get_DeviceNamesByRoomId($RoomId); foreach ($DeviceNames as $DeviceName) { Entertainment_SetDevicePowerByDeviceName($DeviceName, true); } } else { Entertainment_PowerOffUnusedDevices(); } }
function Entertainment_SetSource($SourceId, $Value, $MessageType=c_MessageType_Action) { if (GetValue($SourceId) <> $Value) { $RoomId = IPS_GetParent($SourceId); $SourceName = get_SourceName($RoomId, $Value); IPSLogger_Inf(__file__, 'Set Source "'.$SourceName.'" of Room '.IPS_GetName($RoomId)); SetValue($SourceId, $Value); if (!IsRoomPoweredOn($RoomId)) { Entertainment_SetRoomPowerByRoomId($RoomId, true, false); } Entertainment_SetDeviceControlByRoomId($RoomId, c_Control_Muting, false); Entertainment_SetDevicePowerByRoomId($RoomId, true); Entertainment_SendDataBySourceIdx($RoomId, $Value, $MessageType); Entertainment_SyncRoomControls($RoomId); Entertainment_PowerOffUnusedDevices(); } }