log sentry mode
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m53s
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m53s
This commit is contained in:
parent
0a26850ce4
commit
76bc9708d3
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2567,7 +2567,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tesla-charge-controller"
|
||||
version = "1.0.12"
|
||||
version = "1.0.13"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"chrono",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "tesla-charge-controller"
|
||||
version = "1.0.12"
|
||||
version = "1.0.13"
|
||||
edition = "2021"
|
||||
license = "MITNFA"
|
||||
description = "Controls Tesla charge rate based on solar charge data"
|
||||
|
|
|
@ -40,6 +40,8 @@ struct Metrics {
|
|||
cabin_overheat_protection: CabinOverheatProtectionGauges,
|
||||
hvac_auto: HvacAutoRequestGauges,
|
||||
home: Gauge,
|
||||
sentry_mode: Gauge,
|
||||
sentry_mode_available: Gauge,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
|
@ -88,6 +90,10 @@ impl Metrics {
|
|||
let hvac_auto = HvacAutoRequestGauges::new();
|
||||
describe_gauge!("tesla_home", "Is home");
|
||||
let home = gauge!("tesla_home");
|
||||
describe_gauge!("tesla_sentry_mode", "Sentry mode");
|
||||
let sentry_mode = gauge!("tesla_sentry_mode");
|
||||
describe_gauge!("tesla_sentry_mode_available", "Sentry mode available");
|
||||
let sentry_mode_available = gauge!("tesla_sentry_mode_available");
|
||||
|
||||
Self {
|
||||
battery_level,
|
||||
|
@ -109,6 +115,8 @@ impl Metrics {
|
|||
cabin_overheat_protection,
|
||||
hvac_auto,
|
||||
home,
|
||||
sentry_mode,
|
||||
sentry_mode_available,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -459,6 +467,15 @@ impl TeslaInterface {
|
|||
|
||||
state.climate_state = Some(new_climate_state);
|
||||
}
|
||||
if let Some(new_vehicle_state) = new_state.vehicle_state {
|
||||
self.metrics
|
||||
.sentry_mode
|
||||
.set(obf(new_vehicle_state.sentry_mode));
|
||||
self.metrics
|
||||
.sentry_mode_available
|
||||
.set(obf(new_vehicle_state.sentry_mode_available));
|
||||
state.vehicle_state = Some(new_vehicle_state);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
self.metrics.tesla_online.set(0.);
|
||||
|
@ -518,6 +535,16 @@ impl TeslaInterface {
|
|||
v.into()
|
||||
});
|
||||
|
||||
let vehicle_state = self
|
||||
.api
|
||||
.vehicle_data(&GetVehicleData {
|
||||
vehicle_id: self.vehicle.id,
|
||||
endpoints: vec![Endpoint::VehicleState].into(),
|
||||
})
|
||||
.await?
|
||||
.vehicle_state
|
||||
.map(|v| v.into());
|
||||
|
||||
let (location_data, _) = self
|
||||
.api
|
||||
.vehicle_data(&GetVehicleData {
|
||||
|
@ -555,6 +582,7 @@ impl TeslaInterface {
|
|||
charge_state,
|
||||
location_data,
|
||||
climate_state,
|
||||
vehicle_state,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -566,3 +594,7 @@ fn bf(value: bool) -> f64 {
|
|||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
fn obf(value: Option<bool>) -> f64 {
|
||||
value.map_or(-1., bf)
|
||||
}
|
||||
|
|
16
src/types.rs
16
src/types.rs
|
@ -9,6 +9,7 @@ pub struct CarState {
|
|||
pub charge_state: Option<ChargeState>,
|
||||
pub location_data: Option<LocationData>,
|
||||
pub climate_state: Option<ClimateState>,
|
||||
pub vehicle_state: Option<VehicleState>,
|
||||
}
|
||||
|
||||
impl CarState {
|
||||
|
@ -19,6 +20,21 @@ impl CarState {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
||||
pub struct VehicleState {
|
||||
pub sentry_mode: Option<bool>,
|
||||
pub sentry_mode_available: Option<bool>,
|
||||
}
|
||||
|
||||
impl From<teslatte::vehicles::VehicleState> for VehicleState {
|
||||
fn from(value: teslatte::vehicles::VehicleState) -> Self {
|
||||
Self {
|
||||
sentry_mode: value.sentry_mode,
|
||||
sentry_mode_available: value.sentry_mode_available,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
||||
pub struct ClimateState {
|
||||
pub inside_temp: f64,
|
||||
|
|
Loading…
Reference in a new issue