private string GetCurrentInput() { IPremiseObject switcher = GetSwitcherZone(); if (!switcher.IsValidObject()) { return(""); } IPremiseObject currentInput = switcher.GetRefValueAsync("CurrentSource").GetAwaiter().GetResult(); if (!currentInput.IsValidObject()) { return(""); } return(GetInputName(currentInput)); }
private Dictionary <string, IPremiseObject> GetAllInputs(IPremiseObject switcher) { Dictionary <string, IPremiseObject> inputs = new Dictionary <string, IPremiseObject>(); if (switcher == null) { return(inputs); } // The bound object of the switcher should be the output zone object at the device level IPremiseObject boundObject = switcher.GetRefValueAsync("BoundObject").GetAwaiter().GetResult(); if (!boundObject.IsValidObject()) { string path = switcher.GetPathAsync().GetAwaiter().GetResult(); ReportError(AlexaErrorTypes.ENDPOINT_UNREACHABLE, $"No device bound to switcher at {path}."); return(inputs); } // the parent should be the actual switcher IPremiseObject actualSwitcher = boundObject.GetParentAsync().GetAwaiter().GetResult(); if (!actualSwitcher.IsValidObject()) { string path = boundObject.GetPathAsync().GetAwaiter().GetResult(); ReportError(AlexaErrorTypes.INTERNAL_ERROR, $"Unexpected parent at {path}."); return(inputs); } // walk through the children looking for inputs foreach (IPremiseObject child in actualSwitcher.GetChildrenAsync().GetAwaiter().GetResult()) { if (child.IsOfTypeAsync(PremiseServer.AlexaAudioVideoInput).GetAwaiter().GetResult()) { string inputName = GetInputName(child).ToUpper(); inputs.Add(inputName, child); } } return(inputs); }