lol
This commit is contained in:
parent
c4aa9353a8
commit
40efbea021
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2565,7 +2565,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tesla-charge-controller"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "tesla-charge-controller"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
license = "MITNFA"
|
||||
description = "Controls Tesla charge rate based on solar charge data"
|
||||
|
|
|
@ -33,7 +33,7 @@ fn rocket(state: ServerState) -> rocket::Rocket<rocket::Build> {
|
|||
.attach(Cors)
|
||||
.manage(state)
|
||||
.mount("/", UiStatic {})
|
||||
.mount("/", routes![home, charge_state,])
|
||||
.mount("/", routes![home, charge_state, flash])
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
#[get("/flash")]
|
||||
async fn flash(state: &State<ServerState>) {
|
||||
state.flash().await;
|
||||
}
|
||||
|
||||
impl ServerState {
|
||||
async fn get_coords(&self) -> Result<Coords> {
|
||||
let vehicle_data = self
|
||||
|
@ -147,6 +152,10 @@ impl ServerState {
|
|||
let charge_state = vehicle_data.charge_state.context("no drive state")?;
|
||||
Ok(charge_state.try_into()?)
|
||||
}
|
||||
|
||||
async fn flash(&self) {
|
||||
let _ = self.api.flash_lights(&self.vehicle.vin).await;
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Cors;
|
||||
|
|
Loading…
Reference in a new issue