more data
This commit is contained in:
parent
859326c132
commit
f3018ee9ba
|
@ -18,7 +18,10 @@ use crate::{errors::*, types::CarState};
|
|||
struct Metrics {
|
||||
battery_level: Gauge,
|
||||
charge_rate: Gauge,
|
||||
charge_request: Gauge,
|
||||
inside_temp: Gauge,
|
||||
outside_temp: Gauge,
|
||||
battery_heater: Gauge,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
|
@ -29,14 +32,23 @@ impl Metrics {
|
|||
let battery_level = gauge!("tesla_battery_level");
|
||||
describe_gauge!("tesla_charge_rate", "Charge rate");
|
||||
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_inside_temp", "Inside temperature");
|
||||
let inside_temp = gauge!("tesla_inside_temp");
|
||||
describe_gauge!("tesla_outside_temp", "Outside temperature");
|
||||
let outside_temp = gauge!("tesla_outside_temp");
|
||||
describe_gauge!("tesla_battery_heater", "Battery heater");
|
||||
let battery_heater = gauge!("tesla_battery_heater");
|
||||
|
||||
(
|
||||
Self {
|
||||
battery_level,
|
||||
charge_rate,
|
||||
charge_request,
|
||||
inside_temp,
|
||||
outside_temp,
|
||||
battery_heater,
|
||||
},
|
||||
recorder,
|
||||
)
|
||||
|
@ -136,6 +148,9 @@ impl TeslaInterface {
|
|||
.battery_level
|
||||
.set(new_charge_state.battery_level as f64);
|
||||
self.metrics.charge_rate.set(new_charge_state.charge_rate);
|
||||
self.metrics
|
||||
.charge_request
|
||||
.set(new_charge_state.charge_current_request as f64);
|
||||
state.charge_state = Some(new_charge_state);
|
||||
}
|
||||
if let Some(new_location_data) = new_state.location_data {
|
||||
|
@ -143,6 +158,16 @@ impl TeslaInterface {
|
|||
}
|
||||
if let Some(new_climate_state) = new_state.climate_state {
|
||||
self.metrics.inside_temp.set(new_climate_state.inside_temp);
|
||||
self.metrics
|
||||
.outside_temp
|
||||
.set(new_climate_state.outside_temp);
|
||||
self.metrics
|
||||
.battery_heater
|
||||
.set(if new_climate_state.battery_heater {
|
||||
1.0
|
||||
} else {
|
||||
0.0
|
||||
});
|
||||
state.climate_state = Some(new_climate_state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ pub struct CarState {
|
|||
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
||||
pub struct ClimateState {
|
||||
pub inside_temp: f64,
|
||||
pub outside_temp: f64,
|
||||
pub battery_heater: bool,
|
||||
}
|
||||
|
||||
impl TryFrom<teslatte::vehicles::ClimateState> for ClimateState {
|
||||
|
@ -26,7 +28,12 @@ impl TryFrom<teslatte::vehicles::ClimateState> for ClimateState {
|
|||
Ok(Self {
|
||||
inside_temp: value
|
||||
.inside_temp
|
||||
.context("no temperature in climate data")?,
|
||||
.context("no inside temperature in climate data")?,
|
||||
|
||||
outside_temp: value
|
||||
.outside_temp
|
||||
.context("no outside temperature in climate data")?,
|
||||
battery_heater: value.battery_heater,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue