default state control enable

This commit is contained in:
Alex Janka 2024-01-16 11:10:20 +11:00
parent 560fbf3d7a
commit 79454ff95a
3 changed files with 11 additions and 3 deletions

2
Cargo.lock generated
View file

@ -2256,7 +2256,7 @@ dependencies = [
[[package]] [[package]]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "1.0.0-beta-1" version = "1.0.0-beta-2"
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.0-beta-1" version = "1.0.0-beta-2"
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

@ -23,11 +23,19 @@ pub enum TcrcRequest {
EnableAutomaticControl, EnableAutomaticControl,
} }
#[derive(Default, Clone, Copy, Serialize, Deserialize, Debug)] #[derive(Clone, Copy, Serialize, Deserialize, Debug)]
pub struct TcrcState { pub struct TcrcState {
pub control_enable: bool, pub control_enable: bool,
} }
impl Default for TcrcState {
fn default() -> Self {
Self {
control_enable: true,
}
}
}
impl TeslaChargeRateController { impl TeslaChargeRateController {
pub fn new(car_state: Arc<RwLock<CarState>>, pl_state: Option<Arc<RwLock<PlState>>>) -> Self { pub fn new(car_state: Arc<RwLock<CarState>>, pl_state: Option<Arc<RwLock<PlState>>>) -> Self {
describe_gauge!("tcrc_control_enable", "Enable Tesla charge rate control"); describe_gauge!("tcrc_control_enable", "Enable Tesla charge rate control");