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