public async Task OnGetAsync() { Stopwatch watch = Stopwatch.StartNew(); Lights = await _hueConnector.GetLightsAsync(); Lights = Lights.OrderBy(l => l.Name).ToList(); System.Console.WriteLine($"Hue took {watch.ElapsedMilliseconds}ms"); watch.Restart(); Thermostat = await _ecobeeConnector.GetThermostatAsync(); System.Console.WriteLine($"Thermostat took {watch.ElapsedMilliseconds}ms"); watch.Restart(); RemoteSensors = Thermostat.RemoteSensors.Select(s => (IRemoteSensor)s).ToList(); System.Console.WriteLine($"Thermo Sensors took {watch.ElapsedMilliseconds}ms"); watch.Restart(); //add garage sensors RemoteSensors.AddRange(await _garageSensorConnector.GetSensorsAsync()); System.Console.WriteLine($"Garage Sensors took {watch.ElapsedMilliseconds}ms"); watch.Restart(); Vehicles = (await _teslaConnector.GetVehiclesAsync())?.Vehicles ?? new TeslaVehicle[] { }; System.Console.WriteLine($"Vehicles took {watch.ElapsedMilliseconds}ms"); watch.Restart(); VehicleData = new Dictionary <string, VehicleData>(); if (Vehicles.Any()) { foreach (TeslaVehicle vehicle in Vehicles) { TeslaVehicleDataResponse response = await _teslaConnector.GetVehicleDataAsync(vehicle.IdS); if (response != null) { VehicleData[vehicle.IdS] = response.VehicleData; } } } System.Console.WriteLine($"Vehicle Data took {watch.ElapsedMilliseconds}ms"); watch.Stop(); }
public async Task OnGetAsync() { Lights = await _hueConnector.GetLightsAsync(); Lights = Lights.OrderBy(l => l.Name).ToList(); }
public async Task <ActionResult <List <HueLight> > > GetLights() { return(await _hueConnector.GetLightsAsync()); }