function Entertainment_SyncRoomControls($RoomId) { $RoomName = IPS_GetName($RoomId); $RoomPower = GetValue(get_ControlIdByRoomId($RoomId, c_Control_RoomPower)); $RoomConfig = get_RoomConfiguration(); $ControlTypes = $RoomConfig[$RoomName]; foreach ($ControlTypes as $ControlType=>$ControlData) { if ($ControlType==c_Control_Muting or $ControlType==c_Control_Volume or $ControlType==c_Control_Balance or $ControlType==c_Control_Treble or $ControlType==c_Control_Middle or $ControlType==c_Control_Bass or $ControlType==c_Control_Program or $ControlType==c_Control_RemoteVolume or $ControlType==c_Control_iRemoteVolume or $ControlType==c_Control_RemoteSource or $ControlType==c_Control_iRemoteSource or $ControlType==c_Control_Mode) { $RoomControlId = get_ControlIdByRoomId($RoomId, $ControlType); $DeviceControlId = get_DeviceControlIdByRoomControlId($RoomControlId); if ($DeviceControlId===false and $ControlType==c_Control_iRemoteVolume) { $DeviceControlId = get_DeviceControlIdByRoomControlId($RoomControlId, c_Control_RemoteVolume); } else if ($DeviceControlId===false and $ControlType==c_Control_iRemoteSource) { $DeviceControlId = get_DeviceControlIdByRoomControlId($RoomControlId, c_Control_RemoteSource); } else { // } IPSLogger_Trc(__file__,'Sync Room="'.$RoomName.'", Control="'.$ControlType.'", DeviceControlId='.$DeviceControlId); if ($DeviceControlId!==false) { SetValue($RoomControlId, GetValue($DeviceControlId)); Entertainment_SetRoomControlVisibility($RoomControlId, $RoomPower); } else { Entertainment_SetRoomControlVisibility($RoomControlId, false); } } } }
function Entertainment_SetRoomVisible($PowerId, $Value) { $RoomConfig = get_RoomConfiguration(); $RoomId = IPS_GetParent($PowerId); $RoomName = IPS_GetName($RoomId); $WFRoomName = $RoomConfig[$RoomName][c_Property_Name]; if ($WFRoomName=="") return; $WFRoomId = IPS_GetCategoryIDByName($WFRoomName, c_ID_WebFrontRoomes); $ChildrenIds = IPS_GetChildrenIDs($WFRoomId); foreach($ChildrenIds as $ChildrenIdx => $ChildrenId) { if (IPS_LinkExists($ChildrenId)) { $LinkData = IPS_GetLink($ChildrenId); $LinkedChildId = $LinkData["LinkChildID"]; if ($LinkedChildId <> $PowerId) { IPSLogger_Trc(__file__, 'Set Control "'.IPS_GetName($ChildrenId).'" of Room "'.IPS_GetName($RoomId).'" Visible='.bool2OnOff($Value)); IPS_SetHidden($ChildrenId, !$Value); } } else { $GroupSwitchId = get_ControlIdByRoomId($RoomId, c_Control_Group); IPS_SetHidden($ChildrenId, !GetValue($GroupSwitchId) or !$Value); } } }
function get_ControlNameByRoomName($RoomName, $ControlType) { $RoomData = get_RoomConfiguration(); $Room = $RoomData[$RoomName]; if (array_key_exists($ControlType, $Room)) { return $RoomData[$RoomName][$ControlType][c_Property_Name]; } return false; }