diff --git a/Cargo.lock b/Cargo.lock index 7a6ab1c..dfbd3a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2633,7 +2633,7 @@ dependencies = [ [[package]] name = "tesla-charge-controller" -version = "1.0.27" +version = "1.0.28" dependencies = [ "chrono", "clap 4.4.11", diff --git a/Cargo.toml b/Cargo.toml index 70e2d9a..f0ec111 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tesla-charge-controller" -version = "1.0.27" +version = "1.0.28" edition = "2021" license = "MITNFA" description = "Controls Tesla charge rate based on solar charge data" diff --git a/src/config.rs b/src/config.rs index 90a5fd2..545b76d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -211,8 +211,8 @@ impl Config { fn validate(&mut self) { self.shutoff_voltage = self.shutoff_voltage.clamp(40.0, 60.0); - self.max_rate = self.max_rate.clamp(1, 30); - self.min_rate = self.min_rate.clamp(1, self.max_rate); + self.max_rate = self.max_rate.clamp(0, 30); + self.min_rate = self.min_rate.clamp(0, self.max_rate); self.duty_cycle_too_high = self.duty_cycle_too_high.clamp(0.0, 1.0); self.duty_cycle_too_low = self.duty_cycle_too_low.clamp(0.0, 1.0); self.pid_controls.proportional_gain = self.pid_controls.proportional_gain.clamp(0.0, 50.0); diff --git a/src/server/mod.rs b/src/server/mod.rs index 2704551..15db8f1 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -155,7 +155,7 @@ async fn set_max(limit: i64, remote_addr: std::net::IpAddr) { #[post("/set-min/")] async fn set_min(limit: i64, remote_addr: std::net::IpAddr) { log::warn!("setting min: {remote_addr:?}"); - let limit = limit.clamp(3, access_config().max_rate); + let limit = limit.clamp(0, access_config().max_rate); write_to_config().min_rate = limit; } diff --git a/webapp/index.html b/webapp/index.html index 6e423f0..f78988d 100644 --- a/webapp/index.html +++ b/webapp/index.html @@ -22,10 +22,10 @@

Charge rate:

- +

- +