tesla common dep
This commit is contained in:
parent
1be2476579
commit
29019096e3
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
||||||
[submodule "vendored/teslatte"]
|
|
||||||
path = vendored/teslatte
|
|
||||||
url = ssh://gitea@git.alexjanka.com/alex/teslatte.git
|
|
30
Cargo.lock
generated
30
Cargo.lock
generated
|
@ -485,12 +485,6 @@ dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crunchy"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
|
@ -855,16 +849,6 @@ dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "half"
|
|
||||||
version = "2.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"crunchy",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.14.3"
|
version = "0.14.3"
|
||||||
|
@ -2559,7 +2543,6 @@ dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap 4.4.11",
|
"clap 4.4.11",
|
||||||
"env_logger 0.10.1",
|
"env_logger 0.10.1",
|
||||||
"half",
|
|
||||||
"if_chain",
|
"if_chain",
|
||||||
"include_dir",
|
"include_dir",
|
||||||
"lazy_static 1.4.0",
|
"lazy_static 1.4.0",
|
||||||
|
@ -2572,14 +2555,27 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serialport",
|
"serialport",
|
||||||
|
"tesla-common",
|
||||||
"teslatte",
|
"teslatte",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tesla-common"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "git+https://git.alexjanka.com/alex/tesla-common#6c6cb913c33a94b6246d21af1525fad02b5cd3d8"
|
||||||
|
dependencies = [
|
||||||
|
"ron",
|
||||||
|
"serde",
|
||||||
|
"teslatte",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "teslatte"
|
name = "teslatte"
|
||||||
version = "0.1.11"
|
version = "0.1.11"
|
||||||
|
source = "git+https://git.alexjanka.com/alex/teslatte#cf30a7d1bc78c6f4817fcadf15c1d2b47dce5909"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap 4.4.11",
|
"clap 4.4.11",
|
||||||
|
|
|
@ -13,12 +13,13 @@ depends = ""
|
||||||
assets = [["target/release/tesla-charge-controller", "usr/bin/", "755"]]
|
assets = [["target/release/tesla-charge-controller", "usr/bin/", "755"]]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
teslatte = { git = "https://git.alexjanka.com/alex/teslatte" }
|
||||||
|
tesla-common = { git = "https://git.alexjanka.com/alex/tesla-common" }
|
||||||
clap = { version = "4.0", features = ["derive"] }
|
clap = { version = "4.0", features = ["derive"] }
|
||||||
ron = "0.8"
|
ron = "0.8"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
tokio = { version = "1.35.1", features = ["full"] }
|
tokio = { version = "1.35.1", features = ["full"] }
|
||||||
teslatte = { path = "./vendored/teslatte" }
|
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
rocket = { version = "0.5", features = ["json"] }
|
rocket = { version = "0.5", features = ["json"] }
|
||||||
include_dir = "0.7"
|
include_dir = "0.7"
|
||||||
|
@ -31,4 +32,3 @@ libmodbus-rs = "0.8.3"
|
||||||
if_chain = "1.0.2"
|
if_chain = "1.0.2"
|
||||||
notify-debouncer-mini = { version = "0.4.1", default-features = false }
|
notify-debouncer-mini = { version = "0.4.1", default-features = false }
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
half = "2.3"
|
|
||||||
|
|
|
@ -3,14 +3,13 @@ use prometheus::{
|
||||||
core::{AtomicI64, GenericGauge},
|
core::{AtomicI64, GenericGauge},
|
||||||
register_gauge, register_int_gauge, register_int_gauge_vec, Gauge, IntGauge, IntGaugeVec,
|
register_gauge, register_int_gauge, register_int_gauge_vec, Gauge, IntGauge, IntGaugeVec,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::{
|
use std::{
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
use tesla_common::AuthInfo;
|
||||||
use teslatte::{
|
use teslatte::{
|
||||||
auth::{AccessToken, RefreshToken},
|
|
||||||
error::TeslatteError,
|
error::TeslatteError,
|
||||||
vehicles::{
|
vehicles::{
|
||||||
CabinOverheatProtection, ChargingState, Endpoint, GetVehicleData, HvacAutoRequest,
|
CabinOverheatProtection, ChargingState, Endpoint, GetVehicleData, HvacAutoRequest,
|
||||||
|
@ -262,12 +261,6 @@ struct MonitoredValues {
|
||||||
climate_keeper: String,
|
climate_keeper: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
|
||||||
struct AuthInfo {
|
|
||||||
access_token: AccessToken,
|
|
||||||
refresh_token: Option<RefreshToken>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
// these are the messages that the webserver can send the api thread
|
// these are the messages that the webserver can send the api thread
|
||||||
pub enum InterfaceRequest {
|
pub enum InterfaceRequest {
|
||||||
|
@ -312,14 +305,13 @@ impl TeslaInterface {
|
||||||
Ok(interface)
|
Ok(interface)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_key(&self) -> Result<(), SaveError> {
|
fn save_key(&self) -> Result<(), tesla_common::SaveError> {
|
||||||
std::fs::write(
|
AuthInfo {
|
||||||
self.auth_path.clone(),
|
access_token: self.api.access_token.clone(),
|
||||||
ron::ser::to_string(&AuthInfo {
|
refresh_token: self.api.refresh_token.clone(),
|
||||||
access_token: self.api.access_token.clone(),
|
}
|
||||||
refresh_token: self.api.refresh_token.clone(),
|
.save(Some(&self.auth_path))?;
|
||||||
})?,
|
|
||||||
)?;
|
|
||||||
info!("Auth successfully saved");
|
info!("Auth successfully saved");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,14 +54,6 @@ impl<'a> Responder<'a, 'a> for ServerError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub enum SaveError {
|
|
||||||
#[error("stdio error")]
|
|
||||||
StdIo(#[from] std::io::Error),
|
|
||||||
#[error("ron")]
|
|
||||||
RonSpanned(#[from] ron::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum AuthLoadError {
|
pub enum AuthLoadError {
|
||||||
#[error("stdio error")]
|
#[error("stdio error")]
|
||||||
|
@ -71,7 +63,7 @@ pub enum AuthLoadError {
|
||||||
#[error("teslatte error")]
|
#[error("teslatte error")]
|
||||||
Teslatte(#[from] teslatte::error::TeslatteError),
|
Teslatte(#[from] teslatte::error::TeslatteError),
|
||||||
#[error("save error")]
|
#[error("save error")]
|
||||||
Save(#[from] SaveError),
|
Save(#[from] tesla_common::SaveError),
|
||||||
#[error("no vehicles")]
|
#[error("no vehicles")]
|
||||||
NoVehicles,
|
NoVehicles,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit cf30a7d1bc78c6f4817fcadf15c1d2b47dce5909
|
|
Loading…
Reference in a new issue