2024-01-07 10:08:16 +11:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
|
|
|
pub struct ChargeState {
|
|
|
|
pub battery_level: i64,
|
|
|
|
pub battery_range: f64,
|
|
|
|
pub charge_amps: i64,
|
2024-01-07 10:33:32 +11:00
|
|
|
pub charge_rate: f64,
|
2024-01-07 10:08:16 +11:00
|
|
|
pub charge_current_request: i64,
|
|
|
|
pub charge_current_request_max: i64,
|
|
|
|
pub charge_enable_request: bool,
|
2024-01-07 10:33:32 +11:00
|
|
|
pub charge_limit_soc: i64,
|
2024-01-07 10:08:16 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
impl ChargeState {
|
|
|
|
#[allow(unused)]
|
|
|
|
pub fn range_km(&self) -> f64 {
|
|
|
|
self.battery_range * 1.60934
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<teslatte::vehicles::ChargeState> for ChargeState {
|
|
|
|
fn from(value: teslatte::vehicles::ChargeState) -> Self {
|
|
|
|
ChargeState {
|
|
|
|
battery_level: value.battery_level,
|
|
|
|
battery_range: value.battery_range,
|
|
|
|
charge_amps: value.charge_amps,
|
2024-01-07 10:33:32 +11:00
|
|
|
charge_rate: value.charge_rate,
|
2024-01-07 10:08:16 +11:00
|
|
|
charge_current_request: value.charge_current_request,
|
|
|
|
charge_current_request_max: value.charge_current_request_max,
|
|
|
|
charge_enable_request: value.charge_enable_request,
|
2024-01-07 10:33:32 +11:00
|
|
|
charge_limit_soc: value.charge_limit_soc,
|
2024-01-07 10:08:16 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|