From c0e6009a004f0a57d42bbd38636380e9ce70ee71 Mon Sep 17 00:00:00 2001 From: Maxime Augier Date: Mon, 5 Aug 2024 15:38:44 +0200 Subject: [PATCH] Charger commands (untested) --- src/api.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/api.rs b/src/api.rs index e16d144..1dcdaf9 100644 --- a/src/api.rs +++ b/src/api.rs @@ -411,4 +411,27 @@ impl Charger { pub fn latest_session(&self, ctx: &mut Context) -> Result, ApiError> { 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") + } + + + }