public VehicleOverviewPage(TeslaVehicle vehicle, IProfileService profileService, ITeslaAPIWrapper teslaAPIWrapper) { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { new Label { FontSize = 20, HorizontalTextAlignment = TextAlignment.Center, Text = vehicle.Name, }, }, GestureRecognizers = { new TapGestureRecognizer { Command = new Command(async() => { await Navigation.PushAsync(new ProfilesListPage(vehicle, profileService, teslaAPIWrapper)); }), } } }; }
public ExecuteActionPage(Profile profile, TeslaVehicle vehicle, ITeslaAPIWrapper teslaAPIWrapper) { CurrentActionLabel = new Label { HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, }; Content = CurrentActionLabel; Profile = profile; Vehicle = vehicle; TeslaAPIWrapper = teslaAPIWrapper; }
public ProfilesListPage(TeslaVehicle vehicle, IProfileService profileService, ITeslaAPIWrapper teslaAPIWrapper) { NavigationPage.SetHasNavigationBar(this, false); var listView = new CircleListView { Header = UIUtil.CreateHeaderLabel(vehicle.Name), ItemTemplate = new DataTemplate(() => { Label nameLabel = new Label { HeightRequest = 120, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, }; nameLabel.SetBinding(Label.TextProperty, "Name"); return(new ViewCell { View = new StackLayout { Children = { nameLabel, } } }); }), }; listView.ItemTapped += async(sender, e) => { var binder = (ProfileBinder)e.Item; await Navigation.PushAsync(new ProfileActionPage(binder.Profile, vehicle, profileService, teslaAPIWrapper)); }; ActionButton = new ActionButtonItem { Text = "Create", Command = new Command(async() => { await Navigation.PushAsync(new EditProfilePage(profileService)); }) }; Content = listView; Disposable = profileService .GetProfiles() .Subscribe(updatedList => { LogUtil.Debug("New profiles list count = " + updatedList.Count); listView.ItemsSource = updatedList.Select(p => new ProfileBinder(p)); }); }
private async Task CheckCharging() { _logger.LogDebug("CheckCharging called"); try { var vehicles = await _vehicles.AllVehicles(); foreach (var vehicle in vehicles) { try { var chargeTimeRange = ChargeTimeRange.NextChargeBy(vehicle.ChargingConstraints); TeslaVehicle v = (TeslaVehicle)vehicle; var vs = await v.GetChargeStateAsync(); var plugged_in_text = ""; switch (vs.ChargingState) { case "Disconnected": plugged_in_text = "NOT plugged in"; break; case "Stopped": plugged_in_text = "plugged in but NOT charging"; break; case "Charging": plugged_in_text = "charging"; break; default: plugged_in_text = vs.ChargingState; break; } _logger.LogInformation($"{vehicle.DisplayName} ({vehicle.VIN}) is currently {plugged_in_text}, and is charged to {vs.BatteryLevel}%."); _logger.LogInformation($"Next charge time is between {chargeTimeRange.ChargeNoEarlierThan} and {chargeTimeRange.ChargeBy}, and should be charged to at least {chargeTimeRange.Constraint.MinCharge}% and at most {chargeTimeRange.Constraint.MaxCharge}%"); } catch (System.Exception ex) { _logger.LogError(ex, ex.Message); } } } catch (System.Exception ex) { _logger.LogError(ex, ex.Message); } }
public ProfileActionPage(Profile profile, TeslaVehicle teslaVehicle, IProfileService profileService, ITeslaAPIWrapper teslaAPIWrapper) { NavigationPage.SetHasNavigationBar(this, false); var listView = new CircleListView { Header = UIUtil.CreateHeaderLabel(profile.Name), ItemsSource = new List <string> { "Run", "Edit", "Delete" }, }; listView.ItemTapped += async(sender, e) => { switch (e.Item) { case "Run": await Navigation.PushAsync(new ExecuteActionPage(profile, teslaVehicle, teslaAPIWrapper)); break; case "Edit": await Navigation.PushAsync(new EditProfilePage(profile, profileService)); // Remove this page. After editing the action this list should be gone. Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]); break; case "Delete": await profileService.DeleteProfileAsync(profile); await Navigation.PopAsync(); break; default: break; } }; Content = listView; }
public async Task <CommandResult> SetTemps(TeslaVehicle vehicle, double driverTemp, double passengerTemp) { var commandResult = await teslaClient.SetTemps(vehicle.Id, driverTemp, passengerTemp); return(CommandResult.From(commandResult.Data.Response)); }
public async Task <CommandResult> StopAutoConditioning(TeslaVehicle vehicle) { var commandResult = await teslaClient.StopAutoConditioning(vehicle.Id); return(CommandResult.From(commandResult.Data.Response)); }
public async Task <TeslaVehicle> WakeUp(TeslaVehicle vehicle) { var updatedVehicle = await teslaClient.WakeUpAsync(vehicle.Id); return(TeslaVehicle.From(updatedVehicle.Data.Response)); }
public async Task <List <TeslaVehicle> > GetVehicles() { var apiVehicles = await teslaClient.GetVehiclesAsync(); var vehilces = apiVehicles?.Data.Response.Where(c => c != null).Select(c => TeslaVehicle.From(c)).ToList(); return(vehilces ?? new List <TeslaVehicle>()); }
public async Task <CommandResult> SunRoofControl(TeslaVehicle vehicle, string state) { var commandResult = await teslaClient.SunRoofControl(vehicle.Id, state); return(CommandResult.From(commandResult.Data.Response)); }
public async Task <CommandResult> FlashLights(TeslaVehicle vehicle) { var commandResult = await teslaClient.FlashLights(vehicle.Id); return(CommandResult.From(commandResult.Data.Response)); }
public async Task <CommandResult> ActuateTrunk(TeslaVehicle vehicle, string whichTrunk) { var commandResult = await teslaClient.ActuateTrunk(vehicle.Id, whichTrunk); return(CommandResult.From(commandResult.Data.Response)); }
public async Task <CommandResult> SetChargeLimit(TeslaVehicle vehicle, int percent) { var commandResult = await teslaClient.SetChargeLimit(vehicle.Id, percent); return(CommandResult.From(commandResult.Data.Response)); }
public async Task <CommandResult> ChargeStop(TeslaVehicle vehicle) { var commandResult = await teslaClient.ChargeStop(vehicle.Id); return(CommandResult.From(commandResult.Data.Response)); }
public async Task <CommandResult> SeatHeaterRequest(TeslaVehicle vehicle, int heater, int level) { var commandResult = await teslaClient.SeatHeaterRequest(vehicle.Id, heater, level); return(CommandResult.From(commandResult.Data.Response)); }
public async Task <CommandResult> SteeringWheelHeaterRequest(TeslaVehicle vehicle, bool on) { var commandResult = await teslaClient.SteeringWheelHeaterRequest(vehicle.Id, on); return(CommandResult.From(commandResult.Data.Response)); }
public async Task <CommandResult> HonkHorn(TeslaVehicle vehicle) { var commandResult = await teslaClient.HonkHorn(vehicle.Id); return(CommandResult.From(commandResult.Data.Response)); }