From e7cacafa529299bf5474cc8c70e838ab8a8b2f96 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Thu, 18 Jan 2024 16:32:24 +1100 Subject: [PATCH] version bump + more climate data --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/api_interface.rs | 21 +++++++++++++++++++++ src/types.rs | 6 ++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e96dff6..d6014ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2567,7 +2567,7 @@ dependencies = [ [[package]] name = "tesla-charge-controller" -version = "1.0.7-prerelease" +version = "1.0.7" dependencies = [ "async-channel", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 82ad81e..1e4fe99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tesla-charge-controller" -version = "1.0.7-prerelease" +version = "1.0.7" edition = "2021" license = "MITNFA" description = "Controls Tesla charge rate based on solar charge data" diff --git a/src/api_interface.rs b/src/api_interface.rs index 0faf820..1c25f1f 100644 --- a/src/api_interface.rs +++ b/src/api_interface.rs @@ -29,6 +29,9 @@ struct Metrics { climate_on: Gauge, preconditioning: Gauge, remote_heater_control_enabled: Gauge, + is_auto_conditioning_on: Gauge, + driver_temp_setting: Gauge, + passenger_temp_setting: Gauge, tesla_online: Gauge, charging_state: ChargingStateGauges, } @@ -60,6 +63,12 @@ impl Metrics { "Remote heater control enabled" ); let remote_heater_control_enabled = gauge!("tesla_remote_heater_control_enabled"); + describe_gauge!("tesla_is_auto_conditioning_on", "Auto conditioning on"); + let is_auto_conditioning_on = gauge!("tesla_is_auto_conditioning_on"); + describe_gauge!("tesla_driver_temp_setting", "Driver temp"); + let driver_temp_setting = gauge!("tesla_driver_temp_setting"); + describe_gauge!("tesla_passenger_temp_setting", "Passenger temp"); + let passenger_temp_setting = gauge!("tesla_passenger_temp_setting"); describe_gauge!("tesla_online", "Tesla online"); let tesla_online = gauge!("tesla_online"); describe_gauge!("tesla_charging_state", "Tesla charging state"); @@ -77,6 +86,9 @@ impl Metrics { climate_on, preconditioning, remote_heater_control_enabled, + is_auto_conditioning_on, + driver_temp_setting, + passenger_temp_setting, tesla_online, charging_state, } @@ -301,6 +313,15 @@ impl TeslaInterface { self.metrics .remote_heater_control_enabled .set(bf(new_climate_state.remote_heater_control_enabled)); + self.metrics + .is_auto_conditioning_on + .set(bf(new_climate_state.is_auto_conditioning_on)); + self.metrics + .driver_temp_setting + .set(new_climate_state.driver_temp_setting); + self.metrics + .passenger_temp_setting + .set(new_climate_state.passenger_temp_setting); state.climate_state = Some(new_climate_state); } diff --git a/src/types.rs b/src/types.rs index f286d6e..fd768b1 100644 --- a/src/types.rs +++ b/src/types.rs @@ -27,6 +27,9 @@ pub struct ClimateState { pub climate_on: bool, pub preconditioning: bool, pub remote_heater_control_enabled: bool, + pub is_auto_conditioning_on: bool, + pub driver_temp_setting: f64, + pub passenger_temp_setting: f64, } impl TryFrom for ClimateState { @@ -40,6 +43,9 @@ impl TryFrom for ClimateState { climate_on: value.is_climate_on, preconditioning: value.is_preconditioning, remote_heater_control_enabled: value.remote_heater_control_enabled, + is_auto_conditioning_on: value.is_auto_conditioning_on.unwrap_or(false), + driver_temp_setting: value.driver_temp_setting, + passenger_temp_setting: value.passenger_temp_setting, }) } }