From 3b8f15eb88f8ed8d0336967c38b654ae747e4d01 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Wed, 10 Jul 2024 02:02:43 +0200 Subject: [PATCH] Fixed activating scene --- google_home/google_home/src/traits.rs | 2 +- src/devices/wake_on_lan.rs | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/google_home/google_home/src/traits.rs b/google_home/google_home/src/traits.rs index fbefba3..d7f7a4e 100644 --- a/google_home/google_home/src/traits.rs +++ b/google_home/google_home/src/traits.rs @@ -17,7 +17,7 @@ traits! { "action.devices.traits.Scene" => trait Scene { scene_reversible: Option, - "action.devices.commands.ActivateScene" => async fn set_active(&mut self, activate: bool) -> Result<(), ErrorCode>, + "action.devices.commands.ActivateScene" => async fn set_active(&mut self, deactivate: bool) -> Result<(), ErrorCode>, }, "action.devices.traits.FanSpeed" => trait FanSpeed { reversible: Option, diff --git a/src/devices/wake_on_lan.rs b/src/devices/wake_on_lan.rs index 8b54b27..1a0a35f 100644 --- a/src/devices/wake_on_lan.rs +++ b/src/devices/wake_on_lan.rs @@ -103,8 +103,17 @@ impl google_home::Device for WakeOnLAN { #[async_trait] impl traits::Scene for WakeOnLAN { - async fn set_active(&mut self, activate: bool) -> Result<(), ErrorCode> { - if activate { + async fn set_active(&mut self, deactivate: bool) -> Result<(), ErrorCode> { + if deactivate { + debug!( + id = Device::get_id(self), + "Trying to deactivate computer, this is not currently supported" + ); + // We do not support deactivating this scene + Err(ErrorCode::DeviceError( + google_home::errors::DeviceError::ActionNotAvailable, + )) + } else { debug!( id = Device::get_id(self), "Activating Computer: {} (Sending to {})", @@ -131,15 +140,6 @@ impl traits::Scene for WakeOnLAN { google_home::errors::DeviceError::TransientError.into() }) .map(|_| debug!(id = Device::get_id(self), "Success!")) - } else { - debug!( - id = Device::get_id(self), - "Trying to deactivate computer, this is not currently supported" - ); - // We do not support deactivating this scene - Err(ErrorCode::DeviceError( - google_home::errors::DeviceError::ActionNotAvailable, - )) } } }