log climate/preconditioning/remote heater control enabled
This commit is contained in:
parent
6278c92413
commit
efc43347c7
|
@ -20,6 +20,9 @@ struct Metrics {
|
|||
inside_temp: Gauge,
|
||||
outside_temp: Gauge,
|
||||
battery_heater: Gauge,
|
||||
climate_on: Gauge,
|
||||
preconditioning: Gauge,
|
||||
remote_heater_control_enabled: Gauge,
|
||||
tesla_online: Gauge,
|
||||
}
|
||||
|
||||
|
@ -37,6 +40,15 @@ impl Metrics {
|
|||
let outside_temp = gauge!("tesla_outside_temp");
|
||||
describe_gauge!("tesla_battery_heater", "Battery heater");
|
||||
let battery_heater = gauge!("tesla_battery_heater");
|
||||
describe_gauge!("tesla_climate_on", "Climate control");
|
||||
let climate_on = gauge!("tesla_climate_on");
|
||||
describe_gauge!("tesla_preconditioning", "Preconditioning");
|
||||
let preconditioning = gauge!("tesla_preconditioning");
|
||||
describe_gauge!(
|
||||
"tesla_remote_heater_control_enabled",
|
||||
"Remote heater control enabled"
|
||||
);
|
||||
let remote_heater_control_enabled = gauge!("tesla_remote_heater_control_enabled");
|
||||
describe_gauge!("tesla_online", "Tesla online");
|
||||
let tesla_online = gauge!("tesla_online");
|
||||
|
||||
|
@ -47,6 +59,9 @@ impl Metrics {
|
|||
inside_temp,
|
||||
outside_temp,
|
||||
battery_heater,
|
||||
climate_on,
|
||||
preconditioning,
|
||||
remote_heater_control_enabled,
|
||||
tesla_online,
|
||||
}
|
||||
}
|
||||
|
@ -169,11 +184,16 @@ impl TeslaInterface {
|
|||
.set(new_climate_state.outside_temp);
|
||||
self.metrics
|
||||
.battery_heater
|
||||
.set(if new_climate_state.battery_heater {
|
||||
1.0
|
||||
} else {
|
||||
0.0
|
||||
});
|
||||
.set(bf(new_climate_state.battery_heater));
|
||||
self.metrics
|
||||
.climate_on
|
||||
.set(bf(new_climate_state.climate_on));
|
||||
self.metrics
|
||||
.preconditioning
|
||||
.set(bf(new_climate_state.preconditioning));
|
||||
self.metrics
|
||||
.remote_heater_control_enabled
|
||||
.set(bf(new_climate_state.remote_heater_control_enabled));
|
||||
state.climate_state = Some(new_climate_state);
|
||||
}
|
||||
}
|
||||
|
@ -278,3 +298,11 @@ impl TeslaInterface {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn bf(value: bool) -> f64 {
|
||||
if value {
|
||||
1.0
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ pub struct ClimateState {
|
|||
pub inside_temp: f64,
|
||||
pub outside_temp: f64,
|
||||
pub battery_heater: bool,
|
||||
pub climate_on: bool,
|
||||
pub preconditioning: bool,
|
||||
pub remote_heater_control_enabled: bool,
|
||||
}
|
||||
|
||||
impl TryFrom<teslatte::vehicles::ClimateState> for ClimateState {
|
||||
|
@ -23,9 +26,11 @@ impl TryFrom<teslatte::vehicles::ClimateState> for ClimateState {
|
|||
fn try_from(value: teslatte::vehicles::ClimateState) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
inside_temp: value.inside_temp.ok_or(TeslaStateParseError::NoValue)?,
|
||||
|
||||
outside_temp: value.outside_temp.ok_or(TeslaStateParseError::NoValue)?,
|
||||
battery_heater: value.battery_heater,
|
||||
climate_on: value.is_climate_on,
|
||||
preconditioning: value.is_preconditioning,
|
||||
remote_heater_control_enabled: value.remote_heater_control_enabled,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue