more charge state logging
This commit is contained in:
parent
48b9b02b92
commit
0b5ca36bae
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2256,7 +2256,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tesla-charge-controller"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"chrono",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "tesla-charge-controller"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
edition = "2021"
|
||||
license = "MITNFA"
|
||||
description = "Controls Tesla charge rate based on solar charge data"
|
||||
|
|
|
@ -17,6 +17,8 @@ struct Metrics {
|
|||
battery_level: Gauge,
|
||||
charge_rate: Gauge,
|
||||
charge_request: Gauge,
|
||||
charge_enable_request: Gauge,
|
||||
charger_connected: Gauge,
|
||||
inside_temp: Gauge,
|
||||
outside_temp: Gauge,
|
||||
battery_heater: Gauge,
|
||||
|
@ -34,6 +36,10 @@ impl Metrics {
|
|||
let charge_rate = gauge!("tesla_charge_rate");
|
||||
describe_gauge!("tesla_charge_request", "Requested charge rate");
|
||||
let charge_request = gauge!("tesla_charge_request");
|
||||
describe_gauge!("tesla_charge_enable_request", "Charge enable request");
|
||||
let charge_enable_request = gauge!("tesla_charge_enable_request");
|
||||
describe_gauge!("tesla_charger_connected", "Charger connected");
|
||||
let charger_connected = gauge!("tesla_charger_connected");
|
||||
describe_gauge!("tesla_inside_temp", "Inside temperature");
|
||||
let inside_temp = gauge!("tesla_inside_temp");
|
||||
describe_gauge!("tesla_outside_temp", "Outside temperature");
|
||||
|
@ -56,6 +62,8 @@ impl Metrics {
|
|||
battery_level,
|
||||
charge_rate,
|
||||
charge_request,
|
||||
charge_enable_request,
|
||||
charger_connected,
|
||||
inside_temp,
|
||||
outside_temp,
|
||||
battery_heater,
|
||||
|
@ -74,6 +82,7 @@ pub struct TeslaInterface {
|
|||
last_refresh: Instant,
|
||||
auth_path: PathBuf,
|
||||
metrics: Metrics,
|
||||
last_charging_state: String,
|
||||
last_conn_charge_cable: String,
|
||||
last_cop_state: String,
|
||||
last_climate_keeper: String,
|
||||
|
@ -121,6 +130,7 @@ impl TeslaInterface {
|
|||
auth_path,
|
||||
vehicle,
|
||||
metrics,
|
||||
last_charging_state: String::new(),
|
||||
last_conn_charge_cable: String::new(),
|
||||
last_cop_state: String::new(),
|
||||
last_climate_keeper: String::new(),
|
||||
|
@ -174,6 +184,12 @@ impl TeslaInterface {
|
|||
self.metrics
|
||||
.charge_request
|
||||
.set(new_charge_state.charge_current_request as f64);
|
||||
self.metrics
|
||||
.charge_enable_request
|
||||
.set(bf(new_charge_state.charge_enable_request));
|
||||
self.metrics
|
||||
.charger_connected
|
||||
.set(bf(new_charge_state.charger_connected));
|
||||
state.charge_state = Some(new_charge_state);
|
||||
}
|
||||
if let Some(new_location_data) = new_state.location_data {
|
||||
|
@ -196,6 +212,7 @@ impl TeslaInterface {
|
|||
self.metrics
|
||||
.remote_heater_control_enabled
|
||||
.set(bf(new_climate_state.remote_heater_control_enabled));
|
||||
|
||||
state.climate_state = Some(new_climate_state);
|
||||
}
|
||||
}
|
||||
|
@ -265,6 +282,10 @@ impl TeslaInterface {
|
|||
log::warn!("Current conn charge cable: \"{}\"", v.conn_charge_cable);
|
||||
self.last_conn_charge_cable = v.conn_charge_cable.clone();
|
||||
}
|
||||
if self.last_charging_state != v.charging_state {
|
||||
log::warn!("Current charging state: \"{}\"", v.charging_state);
|
||||
self.last_charging_state = v.charging_state.clone();
|
||||
}
|
||||
v.into()
|
||||
});
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ pub struct ChargeState {
|
|||
pub charge_rate: f64,
|
||||
pub charge_current_request: i64,
|
||||
pub charge_current_request_max: i64,
|
||||
pub charger_connected: bool,
|
||||
pub charge_enable_request: bool,
|
||||
pub charge_limit_soc: i64,
|
||||
}
|
||||
|
@ -56,6 +57,7 @@ impl ChargeState {
|
|||
|
||||
impl From<teslatte::vehicles::ChargeState> for ChargeState {
|
||||
fn from(value: teslatte::vehicles::ChargeState) -> Self {
|
||||
let charger_connected = value.conn_charge_cable == "<invalid>";
|
||||
ChargeState {
|
||||
battery_level: value.battery_level,
|
||||
battery_range: value.battery_range,
|
||||
|
@ -63,6 +65,7 @@ impl From<teslatte::vehicles::ChargeState> for ChargeState {
|
|||
charge_rate: value.charge_rate,
|
||||
charge_current_request: value.charge_current_request,
|
||||
charge_current_request_max: value.charge_current_request_max,
|
||||
charger_connected,
|
||||
charge_enable_request: value.charge_enable_request,
|
||||
charge_limit_soc: value.charge_limit_soc,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue