dont log drive state

This commit is contained in:
Alex Janka 2024-01-18 13:14:49 +11:00
parent ab095973dc
commit 326e4de792
4 changed files with 4 additions and 87 deletions

2
Cargo.lock generated
View file

@ -2256,7 +2256,7 @@ dependencies = [
[[package]] [[package]]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "1.0.5" version = "1.0.6"
dependencies = [ dependencies = [
"async-channel", "async-channel",
"chrono", "chrono",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "1.0.5" version = "1.0.6"
edition = "2021" edition = "2021"
license = "MITNFA" license = "MITNFA"
description = "Controls Tesla charge rate based on solar charge data" description = "Controls Tesla charge rate based on solar charge data"

View file

@ -8,7 +8,7 @@ use std::{
use teslatte::{ use teslatte::{
auth::{AccessToken, RefreshToken}, auth::{AccessToken, RefreshToken},
error::TeslatteError, error::TeslatteError,
vehicles::{ChargingState, Endpoint, GetVehicleData, SetChargingAmps, ShiftState}, vehicles::{ChargingState, Endpoint, GetVehicleData, SetChargingAmps},
FleetApi, FleetVehicleApi, FleetApi, FleetVehicleApi,
}; };
@ -31,9 +31,6 @@ struct Metrics {
remote_heater_control_enabled: Gauge, remote_heater_control_enabled: Gauge,
tesla_online: Gauge, tesla_online: Gauge,
charging_state: ChargingStateGauges, charging_state: ChargingStateGauges,
drive_power: Gauge,
speed: Gauge,
shift_state: ShiftStateGauges,
} }
impl Metrics { impl Metrics {
@ -67,12 +64,6 @@ impl Metrics {
let tesla_online = gauge!("tesla_online"); let tesla_online = gauge!("tesla_online");
describe_gauge!("tesla_charging_state", "Tesla charging state"); describe_gauge!("tesla_charging_state", "Tesla charging state");
let charging_state = ChargingStateGauges::new(); 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 { Self {
battery_level, battery_level,
@ -88,9 +79,6 @@ impl Metrics {
remote_heater_control_enabled, remote_heater_control_enabled,
tesla_online, tesla_online,
charging_state, 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 struct TeslaInterface {
pub state: Arc<RwLock<CarState>>, pub state: Arc<RwLock<CarState>>,
api: FleetApi, api: FleetApi,
@ -359,12 +284,6 @@ impl TeslaInterface {
if let Some(new_location_data) = new_state.location_data { if let Some(new_location_data) = new_state.location_data {
state.location_data = Some(new_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 { if let Some(new_climate_state) = new_state.climate_state {
self.metrics.inside_temp.set(new_climate_state.inside_temp); self.metrics.inside_temp.set(new_climate_state.inside_temp);
self.metrics self.metrics
@ -444,7 +363,7 @@ impl TeslaInterface {
v.into() v.into()
}); });
let (location_data, drive_state) = self let (location_data, _) = self
.api .api
.vehicle_data(&GetVehicleData { .vehicle_data(&GetVehicleData {
vehicle_id: self.vehicle.id, vehicle_id: self.vehicle.id,
@ -492,7 +411,6 @@ impl TeslaInterface {
charge_state, charge_state,
location_data, location_data,
climate_state, climate_state,
drive_state,
}) })
} }
} }

View file

@ -9,7 +9,6 @@ pub struct CarState {
pub charge_state: Option<ChargeState>, pub charge_state: Option<ChargeState>,
pub location_data: Option<LocationData>, pub location_data: Option<LocationData>,
pub climate_state: Option<ClimateState>, pub climate_state: Option<ClimateState>,
pub drive_state: Option<DriveState>,
} }
impl CarState { impl CarState {