feat: added set_scheduled_charging
This commit is contained in:
parent
844583a6b1
commit
cb8df6019a
|
@ -1,5 +1,5 @@
|
||||||
use crate::cli::print_json;
|
use crate::cli::print_json;
|
||||||
use crate::vehicles::{SetChargeLimit, SetChargingAmps};
|
use crate::vehicles::{SetChargeLimit, SetChargingAmps, SetScheduledCharging};
|
||||||
use crate::{Api, VehicleId};
|
use crate::{Api, VehicleId};
|
||||||
use clap::{Args, Subcommand};
|
use clap::{Args, Subcommand};
|
||||||
|
|
||||||
|
@ -31,6 +31,9 @@ pub enum VehicleCommand {
|
||||||
|
|
||||||
/// Stop charging.
|
/// Stop charging.
|
||||||
ChargeStop,
|
ChargeStop,
|
||||||
|
|
||||||
|
/// Set scheduled charging.
|
||||||
|
SetScheduledCharging(SetScheduledCharging),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
|
@ -71,6 +74,12 @@ impl VehicleArgs {
|
||||||
VehicleCommand::ChargeMaxRange => {
|
VehicleCommand::ChargeMaxRange => {
|
||||||
print_json(api.charge_max_range(&self.id).await);
|
print_json(api.charge_max_range(&self.id).await);
|
||||||
}
|
}
|
||||||
|
VehicleCommand::SetScheduledCharging(scheduled_charging) => {
|
||||||
|
print_json(
|
||||||
|
api.set_scheduled_charging(&self.id, &scheduled_charging)
|
||||||
|
.await,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,11 @@ impl Api {
|
||||||
post_arg_empty!(charge_port_door_close, "/vehicles/{}/command/charge_port_door_close", VehicleId);
|
post_arg_empty!(charge_port_door_close, "/vehicles/{}/command/charge_port_door_close", VehicleId);
|
||||||
post_arg!(set_charge_limit, SetChargeLimit, "/vehicles/{}/command/set_charge_limit", VehicleId);
|
post_arg!(set_charge_limit, SetChargeLimit, "/vehicles/{}/command/set_charge_limit", VehicleId);
|
||||||
post_arg!(set_charging_amps, SetChargingAmps, "/vehicles/{}/command/set_charging_amps", VehicleId);
|
post_arg!(set_charging_amps, SetChargingAmps, "/vehicles/{}/command/set_charging_amps", VehicleId);
|
||||||
// TODO: post_arg!(set_charging_scheduled_charging, SetChargingAmps, "/vehicles/{}/command/set_scheduled_charging", VehicleId);
|
|
||||||
post_arg_empty!(charge_standard, "/vehicles/{}/command/charge_standard", VehicleId);
|
post_arg_empty!(charge_standard, "/vehicles/{}/command/charge_standard", VehicleId);
|
||||||
post_arg_empty!(charge_max_range, "/vehicles/{}/command/charge_max_range", VehicleId);
|
post_arg_empty!(charge_max_range, "/vehicles/{}/command/charge_max_range", VehicleId);
|
||||||
post_arg_empty!(charge_start, "/vehicles/{}/command/charge_start", VehicleId);
|
post_arg_empty!(charge_start, "/vehicles/{}/command/charge_start", VehicleId);
|
||||||
post_arg_empty!(charge_stop, "/vehicles/{}/command/charge_stop", VehicleId);
|
post_arg_empty!(charge_stop, "/vehicles/{}/command/charge_stop", VehicleId);
|
||||||
|
post_arg!(set_scheduled_charging, SetScheduledCharging, "/vehicles/{}/command/set_scheduled_charging", VehicleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
@ -326,6 +326,21 @@ pub struct SetChargeLimit {
|
||||||
pub percent: u8,
|
pub percent: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// set_scheduled_charging
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[cfg_attr(feature = "cli", derive(clap::Args))]
|
||||||
|
pub struct SetScheduledCharging {
|
||||||
|
/// Whether scheduled charging is enabled.
|
||||||
|
#[cfg_attr(feature = "cli", clap(short, long))]
|
||||||
|
pub enable: bool,
|
||||||
|
|
||||||
|
/// Minutes after midnight (local time) to start charging. If omitted it will be midnight.
|
||||||
|
///
|
||||||
|
/// NOTE: In the future this will be a time instead of minutes.
|
||||||
|
#[cfg_attr(feature = "cli", clap(short, long))]
|
||||||
|
pub time: Option<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in a new issue