Charger commands (untested)
This commit is contained in:
parent
888c44834a
commit
c0e6009a00
23
src/api.rs
23
src/api.rs
@ -411,4 +411,27 @@ impl Charger {
|
|||||||
pub fn latest_session(&self, ctx: &mut Context) -> Result<Option<ChargingSession>, ApiError> {
|
pub fn latest_session(&self, ctx: &mut Context) -> Result<Option<ChargingSession>, ApiError> {
|
||||||
ctx.maybe_get(&format!("chargers/{}/sessions/latest", &self.id))
|
ctx.maybe_get(&format!("chargers/{}/sessions/latest", &self.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn command(&self, ctx: &mut Context, command: &str) -> Result<(), ApiError> {
|
||||||
|
ctx.post(&format!("chargers/{}/commands/{}", self.id, command), &())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start(&self, ctx: &mut Context) -> Result<(), ApiError> {
|
||||||
|
self.command(ctx, "start_charging")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pause(&self, ctx: &mut Context) -> Result<(), ApiError> {
|
||||||
|
self.command(ctx, "pause_charging")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn resume(&self, ctx: &mut Context) -> Result<(), ApiError> {
|
||||||
|
self.command(ctx, "resume_charging")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn stop(&self, ctx: &mut Context) -> Result<(), ApiError> {
|
||||||
|
self.command(ctx, "stop_charging")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user