"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]]
name = "tesla-charge-controller"
version = "1.1.3"
version = "1.1.4"
dependencies = [
"chrono",
"clap 4.4.11",

View file

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

View file

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