"complete" charge state
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m52s

This commit is contained in:
Alex Janka 2024-01-28 16:21:14 +11:00
parent 45f3ac1b47
commit 8a9b233630
4 changed files with 17 additions and 3 deletions

2
Cargo.lock generated
View file

@ -2554,7 +2554,7 @@ dependencies = [
[[package]] [[package]]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "1.1.3" version = "1.1.4"
dependencies = [ dependencies = [
"chrono", "chrono",
"clap 4.4.11", "clap 4.4.11",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "1.1.3" version = "1.1.4"
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

@ -90,6 +90,7 @@ struct ChargingStateGauges {
charging: GenericGauge<AtomicI64>, charging: GenericGauge<AtomicI64>,
stopped: GenericGauge<AtomicI64>, stopped: GenericGauge<AtomicI64>,
disconnected: GenericGauge<AtomicI64>, disconnected: GenericGauge<AtomicI64>,
complete: GenericGauge<AtomicI64>,
other: GenericGauge<AtomicI64>, other: GenericGauge<AtomicI64>,
} }
@ -98,12 +99,14 @@ impl ChargingStateGauges {
let charging = CHARGING_STATE.with_label_values(&["charging"]); let charging = CHARGING_STATE.with_label_values(&["charging"]);
let stopped = CHARGING_STATE.with_label_values(&["stopped"]); let stopped = CHARGING_STATE.with_label_values(&["stopped"]);
let disconnected = CHARGING_STATE.with_label_values(&["disconnected"]); let disconnected = CHARGING_STATE.with_label_values(&["disconnected"]);
let complete = CHARGING_STATE.with_label_values(&["complete"]);
let other = CHARGING_STATE.with_label_values(&["other"]); let other = CHARGING_STATE.with_label_values(&["other"]);
Self { Self {
charging, charging,
stopped, stopped,
disconnected, disconnected,
complete,
other, other,
} }
} }
@ -114,26 +117,37 @@ impl ChargingStateGauges {
self.charging.set(1); self.charging.set(1);
self.stopped.set(0); self.stopped.set(0);
self.disconnected.set(0); self.disconnected.set(0);
self.complete.set(0);
self.other.set(0); self.other.set(0);
} }
ChargingState::Stopped => { ChargingState::Stopped => {
self.charging.set(0); self.charging.set(0);
self.stopped.set(1); self.stopped.set(1);
self.disconnected.set(0); self.disconnected.set(0);
self.complete.set(0);
self.other.set(0); self.other.set(0);
} }
ChargingState::Disconnected => { ChargingState::Disconnected => {
self.charging.set(0); self.charging.set(0);
self.stopped.set(0); self.stopped.set(0);
self.disconnected.set(1); self.disconnected.set(1);
self.complete.set(0);
self.other.set(0); self.other.set(0);
} }
ChargingState::Other => { ChargingState::Other => {
self.charging.set(0); self.charging.set(0);
self.stopped.set(0); self.stopped.set(0);
self.disconnected.set(0); self.disconnected.set(0);
self.complete.set(0);
self.other.set(1); self.other.set(1);
} }
ChargingState::Complete => {
self.charging.set(0);
self.stopped.set(0);
self.disconnected.set(0);
self.complete.set(1);
self.other.set(0);
}
} }
} }
} }

@ -1 +1 @@
Subproject commit a350280662bfca096ea153903bdc3dcb2652f415 Subproject commit cf30a7d1bc78c6f4817fcadf15c1d2b47dce5909