log whether is at home
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m51s

This commit is contained in:
Alex Janka 2024-01-21 09:48:54 +11:00
parent 99c5d23d35
commit 0a26850ce4
3 changed files with 7 additions and 2 deletions

2
Cargo.lock generated
View file

@ -2567,7 +2567,7 @@ dependencies = [
[[package]] [[package]]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "1.0.11" version = "1.0.12"
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.11" version = "1.0.12"
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

@ -39,6 +39,7 @@ struct Metrics {
charging_state: ChargingStateGauges, charging_state: ChargingStateGauges,
cabin_overheat_protection: CabinOverheatProtectionGauges, cabin_overheat_protection: CabinOverheatProtectionGauges,
hvac_auto: HvacAutoRequestGauges, hvac_auto: HvacAutoRequestGauges,
home: Gauge,
} }
impl Metrics { impl Metrics {
@ -85,6 +86,8 @@ impl Metrics {
let cabin_overheat_protection = CabinOverheatProtectionGauges::new(); let cabin_overheat_protection = CabinOverheatProtectionGauges::new();
describe_gauge!("tesla_hvac_auto_request", "HVAC auto"); describe_gauge!("tesla_hvac_auto_request", "HVAC auto");
let hvac_auto = HvacAutoRequestGauges::new(); let hvac_auto = HvacAutoRequestGauges::new();
describe_gauge!("tesla_home", "Is home");
let home = gauge!("tesla_home");
Self { Self {
battery_level, battery_level,
@ -105,6 +108,7 @@ impl Metrics {
charging_state, charging_state,
cabin_overheat_protection, cabin_overheat_protection,
hvac_auto, hvac_auto,
home,
} }
} }
} }
@ -417,6 +421,7 @@ impl TeslaInterface {
state.charge_state = Some(new_charge_state); state.charge_state = Some(new_charge_state);
} }
if let Some(new_location_data) = new_state.location_data { if let Some(new_location_data) = new_state.location_data {
self.metrics.home.set(bf(new_location_data.home));
state.location_data = Some(new_location_data); state.location_data = Some(new_location_data);
} }
if let Some(new_climate_state) = new_state.climate_state { if let Some(new_climate_state) = new_state.climate_state {