charge cable loggen

This commit is contained in:
Alex Janka 2024-01-15 13:19:53 +11:00
parent df17b8d66c
commit 9b77c7854e

View file

@ -74,6 +74,7 @@ pub struct TeslaInterface {
last_refresh: Instant, last_refresh: Instant,
auth_path: PathBuf, auth_path: PathBuf,
metrics: Metrics, metrics: Metrics,
last_conn_charge_cable: String,
last_cop_state: String, last_cop_state: String,
last_climate_keeper: String, last_climate_keeper: String,
last_hvac_auto: String, last_hvac_auto: String,
@ -120,6 +121,7 @@ impl TeslaInterface {
auth_path, auth_path,
vehicle, vehicle,
metrics, metrics,
last_conn_charge_cable: String::new(),
last_cop_state: String::new(), last_cop_state: String::new(),
last_climate_keeper: String::new(), last_climate_keeper: String::new(),
last_hvac_auto: String::new(), last_hvac_auto: String::new(),
@ -258,7 +260,13 @@ impl TeslaInterface {
}) })
.await? .await?
.charge_state .charge_state
.map(|v| v.into()); .map(|v| {
if self.last_conn_charge_cable != v.conn_charge_cable {
log::warn!("Current conn charge cable: \"{}\"", v.conn_charge_cable);
self.last_conn_charge_cable = v.conn_charge_cable.clone();
}
v.into()
});
let location_data = self let location_data = self
.api .api
@ -281,17 +289,17 @@ impl TeslaInterface {
.and_then(|v| { .and_then(|v| {
if self.last_cop_state != v.cabin_overheat_protection { if self.last_cop_state != v.cabin_overheat_protection {
log::warn!( log::warn!(
"Current cabin overheat protection state: {}", "Current cabin overheat protection state: \"{}\"",
v.cabin_overheat_protection v.cabin_overheat_protection
); );
self.last_cop_state = v.cabin_overheat_protection.clone(); self.last_cop_state = v.cabin_overheat_protection.clone();
} }
if self.last_climate_keeper != v.climate_keeper_mode { if self.last_climate_keeper != v.climate_keeper_mode {
log::warn!("Current climate keeper mode: {}", v.climate_keeper_mode); log::warn!("Current climate keeper mode: \"{}\"", v.climate_keeper_mode);
self.last_climate_keeper = v.climate_keeper_mode.clone(); self.last_climate_keeper = v.climate_keeper_mode.clone();
} }
if self.last_hvac_auto != v.hvac_auto_request { if self.last_hvac_auto != v.hvac_auto_request {
log::warn!("HVAC auto request set to: {}", v.hvac_auto_request); log::warn!("HVAC auto request set to: \"{}\"", v.hvac_auto_request);
self.last_hvac_auto = v.hvac_auto_request.clone(); self.last_hvac_auto = v.hvac_auto_request.clone();
} }
v.try_into().ok() v.try_into().ok()