function Entertainment_TurnOffAllRoomesAndDevices() { IPSLogger_Inf(__file__, 'Turn Off all Roomes and Devices'); $RoomIds = get_ActiveRoomIds(); foreach ($RoomIds as $RoomId) { Entertainment_SetRoomPowerByRoomId($RoomId, false); } Entertainment_PowerOffUnusedDevices(); }
function Entertainment_SetRoomPowerByDeviceName($DeviceName, $Value) { if ($Value) { $SourceList = get_SourceListByDeviceName($DeviceName, $Value); if (count($SourceList)==1) { $RoomKeys = array_keys($SourceList); $RoomId = $RoomKeys[0]; $SourceIdx = $SourceList[$RoomId]; if (!IsRoomPoweredOn($RoomId)) { Entertainment_SetRoomPowerByRoomId($RoomId, true, false); Entertainment_SetSourceByRoomId($RoomId, $SourceIdx); } } } else { $RoomId = get_RoomIdByOutputDevice($DeviceName); if ($RoomId!==false and IsRoomPoweredOn($RoomId)) { Entertainment_SetRoomPowerByRoomId($RoomId, false); } } }
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(); } }