log some more fields
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m53s

This commit is contained in:
Alex Janka 2024-01-23 15:31:27 +11:00
parent 4e7f6a0616
commit 73b3a90462
4 changed files with 48 additions and 2 deletions

2
Cargo.lock generated
View file

@ -2633,7 +2633,7 @@ dependencies = [
[[package]]
name = "tesla-charge-controller"
version = "1.0.26"
version = "1.0.27"
dependencies = [
"chrono",
"clap 4.4.11",

View file

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

View file

@ -42,6 +42,11 @@ struct Metrics {
home: Gauge,
sentry_mode: Gauge,
sentry_mode_available: Gauge,
charger_actual_current: Gauge,
charger_phases: Gauge,
charger_pilot_current: Gauge,
charger_power: Gauge,
charger_voltage: Gauge,
}
impl Metrics {
@ -95,6 +100,17 @@ impl Metrics {
describe_gauge!("tesla_sentry_mode_available", "Sentry mode available");
let sentry_mode_available = gauge!("tesla_sentry_mode_available");
describe_gauge!("tesla_charger_actual_current", "Charger actual current");
let charger_actual_current = gauge!("tesla_charger_actual_current");
describe_gauge!("tesla_charger_phases", "Charger phases");
let charger_phases = gauge!("tesla_charger_phases");
describe_gauge!("tesla_charger_pilot_current", "Charger pilot current");
let charger_pilot_current = gauge!("tesla_charger_pilot_current");
describe_gauge!("tesla_charger_power", "Charger power");
let charger_power = gauge!("tesla_charger_power");
describe_gauge!("tesla_charger_voltage", "Charger voltage");
let charger_voltage = gauge!("tesla_charger_voltage");
Self {
battery_level,
charge_rate,
@ -117,6 +133,11 @@ impl Metrics {
home,
sentry_mode,
sentry_mode_available,
charger_actual_current,
charger_phases,
charger_pilot_current,
charger_power,
charger_voltage,
}
}
}
@ -425,6 +446,21 @@ impl TeslaInterface {
self.metrics
.charging_state
.set(new_charge_state.charging_state);
if let Some(v) = new_charge_state.charger_actual_current {
self.metrics.charger_actual_current.set(v as f64);
}
if let Some(v) = new_charge_state.charger_phases {
self.metrics.charger_phases.set(v as f64);
}
if let Some(v) = new_charge_state.charger_pilot_current {
self.metrics.charger_pilot_current.set(v as f64);
}
if let Some(v) = new_charge_state.charger_power {
self.metrics.charger_power.set(v as f64);
}
if let Some(v) = new_charge_state.charger_voltage {
self.metrics.charger_voltage.set(v as f64);
}
state.charge_state = Some(new_charge_state);
}
if let Some(new_location_data) = new_state.location_data {

View file

@ -82,6 +82,11 @@ pub struct ChargeState {
pub charge_enable_request: bool,
pub charging_state: ChargingState,
pub charge_limit_soc: i64,
pub charger_actual_current: Option<i64>,
pub charger_phases: Option<i64>,
pub charger_pilot_current: Option<i64>,
pub charger_power: Option<i64>,
pub charger_voltage: Option<i64>,
}
impl From<teslatte::vehicles::ChargeState> for ChargeState {
@ -97,6 +102,11 @@ impl From<teslatte::vehicles::ChargeState> for ChargeState {
charge_enable_request: value.charge_enable_request,
charging_state: value.charging_state,
charge_limit_soc: value.charge_limit_soc,
charger_actual_current: value.charger_actual_current,
charger_phases: value.charger_phases,
charger_pilot_current: value.charger_pilot_current,
charger_power: value.charger_power,
charger_voltage: value.charger_voltage,
}
}
}