async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); await hass.Initialize(); var items = new ObservableCollection <IComponent>(); foreach (IComponent c in hass.AllEntities) { items.Add(c); } ShellContext.BeginInvokeOnMainThread(() => { Items = items; OnPropertyChanged(nameof(Items)); SelectedComponent = items.FirstOrDefault(); }); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public void InitializeTest() { WsAPI.Instance = Mock.Factory.CreateMockIHassAPI(); var hass = new HassSystem(); hass.Initialize().Wait(); Assert.IsNotNull(hass.AllEntities); }