dont log drive state
This commit is contained in:
parent
ab095973dc
commit
326e4de792
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2256,7 +2256,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tesla-charge-controller"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"chrono",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "tesla-charge-controller"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
edition = "2021"
|
||||
license = "MITNFA"
|
||||
description = "Controls Tesla charge rate based on solar charge data"
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
use teslatte::{
|
||||
auth::{AccessToken, RefreshToken},
|
||||
error::TeslatteError,
|
||||
vehicles::{ChargingState, Endpoint, GetVehicleData, SetChargingAmps, ShiftState},
|
||||
vehicles::{ChargingState, Endpoint, GetVehicleData, SetChargingAmps},
|
||||
FleetApi, FleetVehicleApi,
|
||||
};
|
||||
|
||||
|
@ -31,9 +31,6 @@ struct Metrics {
|
|||
remote_heater_control_enabled: Gauge,
|
||||
tesla_online: Gauge,
|
||||
charging_state: ChargingStateGauges,
|
||||
drive_power: Gauge,
|
||||
speed: Gauge,
|
||||
shift_state: ShiftStateGauges,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
|
@ -67,12 +64,6 @@ impl Metrics {
|
|||
let tesla_online = gauge!("tesla_online");
|
||||
describe_gauge!("tesla_charging_state", "Tesla charging state");
|
||||
let charging_state = ChargingStateGauges::new();
|
||||
describe_gauge!("tesla_drive_power", "Tesla drive power");
|
||||
let drive_power = gauge!("tesla_drive_power");
|
||||
describe_gauge!("tesla_speed", "Tesla speed");
|
||||
let speed = gauge!("tesla_speed");
|
||||
describe_gauge!("tesla_shift_state", "Currently selected gear");
|
||||
let shift_state = ShiftStateGauges::new();
|
||||
|
||||
Self {
|
||||
battery_level,
|
||||
|
@ -88,9 +79,6 @@ impl Metrics {
|
|||
remote_heater_control_enabled,
|
||||
tesla_online,
|
||||
charging_state,
|
||||
drive_power,
|
||||
speed,
|
||||
shift_state,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -158,69 +146,6 @@ impl ChargingStateGauges {
|
|||
}
|
||||
}
|
||||
|
||||
struct ShiftStateGauges {
|
||||
drive: Gauge,
|
||||
neutral: Gauge,
|
||||
reverse: Gauge,
|
||||
park: Gauge,
|
||||
}
|
||||
|
||||
impl ShiftStateGauges {
|
||||
fn new() -> Self {
|
||||
let drive = gauge!(
|
||||
"tesla_shift_state",
|
||||
vec![Label::new("state", String::from("drive"))]
|
||||
);
|
||||
let reverse = gauge!(
|
||||
"tesla_shift_state",
|
||||
vec![Label::new("state", String::from("reverse"))]
|
||||
);
|
||||
let neutral = gauge!(
|
||||
"tesla_shift_state",
|
||||
vec![Label::new("state", String::from("neutral"))]
|
||||
);
|
||||
let park = gauge!(
|
||||
"tesla_shift_state",
|
||||
vec![Label::new("state", String::from("park"))]
|
||||
);
|
||||
Self {
|
||||
drive,
|
||||
reverse,
|
||||
neutral,
|
||||
park,
|
||||
}
|
||||
}
|
||||
|
||||
fn set(&mut self, state: ShiftState) {
|
||||
match state {
|
||||
ShiftState::Drive => {
|
||||
self.drive.set(1.);
|
||||
self.neutral.set(0.);
|
||||
self.reverse.set(0.);
|
||||
self.park.set(0.);
|
||||
}
|
||||
ShiftState::Neutral => {
|
||||
self.drive.set(0.);
|
||||
self.neutral.set(1.);
|
||||
self.reverse.set(0.);
|
||||
self.park.set(0.);
|
||||
}
|
||||
ShiftState::Reverse => {
|
||||
self.drive.set(0.);
|
||||
self.neutral.set(0.);
|
||||
self.reverse.set(1.);
|
||||
self.park.set(0.);
|
||||
}
|
||||
ShiftState::Park => {
|
||||
self.drive.set(0.);
|
||||
self.neutral.set(0.);
|
||||
self.reverse.set(0.);
|
||||
self.park.set(1.);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TeslaInterface {
|
||||
pub state: Arc<RwLock<CarState>>,
|
||||
api: FleetApi,
|
||||
|
@ -359,12 +284,6 @@ impl TeslaInterface {
|
|||
if let Some(new_location_data) = new_state.location_data {
|
||||
state.location_data = Some(new_location_data);
|
||||
}
|
||||
if let Some(new_drive_state) = new_state.drive_state {
|
||||
self.metrics.drive_power.set(new_drive_state.power as f64);
|
||||
self.metrics.speed.set(new_drive_state.speed as f64);
|
||||
self.metrics.shift_state.set(new_drive_state.shift_state);
|
||||
state.drive_state = Some(new_drive_state);
|
||||
}
|
||||
if let Some(new_climate_state) = new_state.climate_state {
|
||||
self.metrics.inside_temp.set(new_climate_state.inside_temp);
|
||||
self.metrics
|
||||
|
@ -444,7 +363,7 @@ impl TeslaInterface {
|
|||
v.into()
|
||||
});
|
||||
|
||||
let (location_data, drive_state) = self
|
||||
let (location_data, _) = self
|
||||
.api
|
||||
.vehicle_data(&GetVehicleData {
|
||||
vehicle_id: self.vehicle.id,
|
||||
|
@ -492,7 +411,6 @@ impl TeslaInterface {
|
|||
charge_state,
|
||||
location_data,
|
||||
climate_state,
|
||||
drive_state,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ pub struct CarState {
|
|||
pub charge_state: Option<ChargeState>,
|
||||
pub location_data: Option<LocationData>,
|
||||
pub climate_state: Option<ClimateState>,
|
||||
pub drive_state: Option<DriveState>,
|
||||
}
|
||||
|
||||
impl CarState {
|
||||
|
|
Loading…
Reference in a new issue