lol
This commit is contained in:
parent
c4aa9353a8
commit
40efbea021
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2565,7 +2565,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tesla-charge-controller"
|
name = "tesla-charge-controller"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tesla-charge-controller"
|
name = "tesla-charge-controller"
|
||||||
version = "0.1.1"
|
version = "0.1.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"
|
||||||
|
|
|
@ -33,7 +33,7 @@ fn rocket(state: ServerState) -> rocket::Rocket<rocket::Build> {
|
||||||
.attach(Cors)
|
.attach(Cors)
|
||||||
.manage(state)
|
.manage(state)
|
||||||
.mount("/", UiStatic {})
|
.mount("/", UiStatic {})
|
||||||
.mount("/", routes![home, charge_state,])
|
.mount("/", routes![home, charge_state, flash])
|
||||||
}
|
}
|
||||||
|
|
||||||
static UI_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/../client/dist");
|
static UI_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/../client/dist");
|
||||||
|
@ -118,6 +118,11 @@ async fn charge_state(state: &State<ServerState>) -> Option<Json<shared_types::C
|
||||||
Some(Json(charge_state))
|
Some(Json(charge_state))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/flash")]
|
||||||
|
async fn flash(state: &State<ServerState>) {
|
||||||
|
state.flash().await;
|
||||||
|
}
|
||||||
|
|
||||||
impl ServerState {
|
impl ServerState {
|
||||||
async fn get_coords(&self) -> Result<Coords> {
|
async fn get_coords(&self) -> Result<Coords> {
|
||||||
let vehicle_data = self
|
let vehicle_data = self
|
||||||
|
@ -147,6 +152,10 @@ impl ServerState {
|
||||||
let charge_state = vehicle_data.charge_state.context("no drive state")?;
|
let charge_state = vehicle_data.charge_state.context("no drive state")?;
|
||||||
Ok(charge_state.try_into()?)
|
Ok(charge_state.try_into()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn flash(&self) {
|
||||||
|
let _ = self.api.flash_lights(&self.vehicle.vin).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Cors;
|
pub struct Cors;
|
||||||
|
|
Loading…
Reference in a new issue