public async Task Start() { var client = new TeslaClient(true); await client.LogInAsync("username", "password"); if (client.IsLoggedIn) { var cars = await client.LoadVehiclesAsync(); var car = cars.FirstOrDefault(); const bool showUnchanged = true; WriteModifiedFields(await client.AnalyzeFieldsAsync <TeslaVehicle>(client.TESLA_SERVER, client.VEHICLES_PATH), showUnchanged); WriteModifiedFields(await client.AnalyzeFieldsAsync <ChargeStateStatus>(client.TESLA_SERVER, string.Format(client.CHARGE_STATE_PATH, car.Id)), showUnchanged); WriteModifiedFields(await client.AnalyzeFieldsAsync <ClimateStateStatus>(client.TESLA_SERVER, string.Format(client.CLIMATE_STATE_PATH, car.Id)), showUnchanged); WriteModifiedFields(await client.AnalyzeFieldsAsync <DriveStateStatus>(client.TESLA_SERVER, string.Format(client.DRIVE_STATE_PATH, car.Id)), showUnchanged); WriteModifiedFields(await client.AnalyzeFieldsAsync <GuiSettingsStatus>(client.TESLA_SERVER, string.Format(client.GUI_SETTINGS_PATH, car.Id)), showUnchanged); WriteModifiedFields(await client.AnalyzeFieldsAsync <MobileEnabledStatus>(client.TESLA_SERVER, string.Format(client.MOBILE_ENABLED_PATH, car.Id)), showUnchanged); WriteModifiedFields(await client.AnalyzeFieldsAsync <VehicleStateStatus>(client.TESLA_SERVER, string.Format(client.VEHICLE_STATE_PATH, car.Id)), showUnchanged); } }
public async Task Start() { var client = new TeslaClient(true); await client.LogInAsync("username", "password"); Console.WriteLine("Logged In: " + client.IsLoggedIn); Console.WriteLine(); if (client.IsLoggedIn) { var cars = await client.LoadVehiclesAsync(); if (cars.Count == 0) { Console.WriteLine("Error: You do not have access to any vehicles"); return; } Console.WriteLine("Vehicles:"); foreach (var c in cars) { Console.WriteLine(c.Id + " " + c.VIN); } var car = cars.FirstOrDefault(); if (car == null) { return; } var a = client.LoadChargeStateStatus(car); Console.WriteLine("Charging State: " + a.ChargingState); Console.WriteLine("Battery Range: " + a.BatteryRange); } }