private static async Task Init() { bearer = GetToken(); client = new HttpClient(); api = new AwairService(client, bearer); devices = await api.GetDevicesAsync(); }
public async Task <MultiDeviceRawData> GetAllDevicePastHourRawData(QuickType.Devices devices) { using var x = new DisposableTrace("GetPastHour"); DateTime to = DateTime.UtcNow; var from = to.AddHours(-1.0); var calls = devices.DevicesDevices.Select(x => GetDeviceRawAirDataAsync(x, from, to, UseFahrenheit)); var raws = (await Task.WhenAll(calls)).ToList(); var multidata = new MultiDeviceRawData(raws); return(multidata); }
public async Task AssignDeviceColors(QuickType.Devices devices) { foreach (var d in devices.DevicesDevices) { var colorval = new LocalStorageValue <int>($"{d.DeviceUuid}_Color", localStore); if (await colorval.Exists()) { d.Color = Color.FromArgb(await colorval.RefreshValueAsync()); } else { // save a new random color for this device await colorval.SetValueAsync(d.RandomizeColor().ToArgb()); } } }