feat: set_scheduled_departure
This commit is contained in:
parent
67058aab47
commit
8b96ecf3bc
|
@ -1,5 +1,7 @@
|
|||
use crate::cli::print_json;
|
||||
use crate::vehicles::{SetChargeLimit, SetChargingAmps, SetScheduledCharging};
|
||||
use crate::vehicles::{
|
||||
SetChargeLimit, SetChargingAmps, SetScheduledCharging, SetScheduledDeparture,
|
||||
};
|
||||
use crate::{Api, VehicleId};
|
||||
use clap::{Args, Subcommand};
|
||||
|
||||
|
@ -34,6 +36,9 @@ pub enum VehicleCommand {
|
|||
|
||||
/// Set scheduled charging.
|
||||
SetScheduledCharging(SetScheduledCharging),
|
||||
|
||||
/// Set scheduled departure.
|
||||
SetScheduledDeparture(SetScheduledDeparture),
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
|
@ -74,11 +79,11 @@ impl VehicleArgs {
|
|||
VehicleCommand::ChargeMaxRange => {
|
||||
print_json(api.charge_max_range(&self.id).await);
|
||||
}
|
||||
VehicleCommand::SetScheduledCharging(scheduled_charging) => {
|
||||
print_json(
|
||||
api.set_scheduled_charging(&self.id, &scheduled_charging)
|
||||
.await,
|
||||
);
|
||||
VehicleCommand::SetScheduledCharging(charging) => {
|
||||
print_json(api.set_scheduled_charging(&self.id, &charging).await);
|
||||
}
|
||||
VehicleCommand::SetScheduledDeparture(departure) => {
|
||||
print_json(api.set_scheduled_departure(&self.id, &departure).await);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -20,6 +20,7 @@ impl Api {
|
|||
post_arg_empty!(charge_start, "/vehicles/{}/command/charge_start", VehicleId);
|
||||
post_arg_empty!(charge_stop, "/vehicles/{}/command/charge_stop", VehicleId);
|
||||
post_arg!(set_scheduled_charging, SetScheduledCharging, "/vehicles/{}/command/set_scheduled_charging", VehicleId);
|
||||
post_arg!(set_scheduled_departure, SetScheduledDeparture, "/vehicles/{}/command/set_scheduled_departure", VehicleId);
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
|
@ -341,6 +342,38 @@ pub struct SetScheduledCharging {
|
|||
pub time: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[cfg_attr(feature = "cli", derive(clap::Args))]
|
||||
pub struct SetScheduledDeparture {
|
||||
/// Whether scheduled departure is enabled.
|
||||
#[cfg_attr(feature = "cli", clap(short, long))]
|
||||
pub enable: bool,
|
||||
|
||||
/// Minutes after midnight (local time) to depart.
|
||||
///
|
||||
/// NOTE: In the future this will be a time instead of minutes.
|
||||
#[cfg_attr(feature = "cli", clap(short, long))]
|
||||
pub departure_time: Option<u64>,
|
||||
|
||||
#[cfg_attr(feature = "cli", clap(short, long))]
|
||||
pub preconditioning_enabled: bool,
|
||||
|
||||
#[cfg_attr(feature = "cli", clap(short = 'w', long))]
|
||||
pub preconditioning_weekdays_only: bool,
|
||||
|
||||
#[cfg_attr(feature = "cli", clap(short, long))]
|
||||
pub off_peak_charging_enabled: bool,
|
||||
|
||||
#[cfg_attr(feature = "cli", clap(short = 'y', long))]
|
||||
pub off_peak_charging_weekdays_only: bool,
|
||||
|
||||
/// Minutes after midnight (local time) to end off peak charging.
|
||||
///
|
||||
/// NOTE: In the future this will be a time instead of minutes.
|
||||
#[cfg_attr(feature = "cli", clap(short = 'n', long))]
|
||||
pub end_off_peak_time: Option<u64>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue