rates minimum to 0
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m54s

This commit is contained in:
Alex Janka 2024-01-24 15:59:22 +11:00
parent 73b3a90462
commit 95a0a446a1
5 changed files with 7 additions and 7 deletions

2
Cargo.lock generated
View file

@ -2633,7 +2633,7 @@ dependencies = [
[[package]] [[package]]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "1.0.27" version = "1.0.28"
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.0.27" version = "1.0.28"
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

@ -211,8 +211,8 @@ impl Config {
fn validate(&mut self) { fn validate(&mut self) {
self.shutoff_voltage = self.shutoff_voltage.clamp(40.0, 60.0); self.shutoff_voltage = self.shutoff_voltage.clamp(40.0, 60.0);
self.max_rate = self.max_rate.clamp(1, 30); self.max_rate = self.max_rate.clamp(0, 30);
self.min_rate = self.min_rate.clamp(1, self.max_rate); 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_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.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); self.pid_controls.proportional_gain = self.pid_controls.proportional_gain.clamp(0.0, 50.0);

View file

@ -155,7 +155,7 @@ async fn set_max(limit: i64, remote_addr: std::net::IpAddr) {
#[post("/set-min/<limit>")] #[post("/set-min/<limit>")]
async fn set_min(limit: i64, remote_addr: std::net::IpAddr) { async fn set_min(limit: i64, remote_addr: std::net::IpAddr) {
log::warn!("setting min: {remote_addr:?}"); 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; write_to_config().min_rate = limit;
} }

View file

@ -22,10 +22,10 @@
<div id="rate-control"> <div id="rate-control">
<h3>Charge rate:</h3> <h3>Charge rate:</h3>
<input type="number" id="max-rate" max="15" min="3" onchange="change_max()" autocomplete="off" /> <input type="number" id="max-rate" max="15" min="0" onchange="change_max()" autocomplete="off" />
<button id="set-maximum" onclick="set_maximum()" disabled>Set maximum</button> <button id="set-maximum" onclick="set_maximum()" disabled>Set maximum</button>
<br><br> <br><br>
<input type="number" id="min-rate" max="15" min="3" onchange="change_min()" autocomplete="off" /> <input type="number" id="min-rate" max="15" min="0" onchange="change_min()" autocomplete="off" />
<button id="set-minimum" onclick="set_minimum()" disabled>Set minimum</button> <button id="set-minimum" onclick="set_minimum()" disabled>Set minimum</button>
</div> </div>
<div id="info"></div> <div id="info"></div>