Fixed activating scene
All checks were successful
Build and deploy / Build application (push) Successful in 3m51s
Check / Run checks (push) Successful in 2m37s
Build and deploy / Build container (push) Successful in 1m8s
Build and deploy / Deploy container (push) Successful in 36s

This commit is contained in:
Dreaded_X 2024-07-10 02:02:43 +02:00
parent f7b709a2c7
commit 3b8f15eb88
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
2 changed files with 12 additions and 12 deletions

View File

@ -17,7 +17,7 @@ traits! {
"action.devices.traits.Scene" => trait Scene { "action.devices.traits.Scene" => trait Scene {
scene_reversible: Option<bool>, scene_reversible: Option<bool>,
"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 { "action.devices.traits.FanSpeed" => trait FanSpeed {
reversible: Option<bool>, reversible: Option<bool>,

View File

@ -103,8 +103,17 @@ impl google_home::Device for WakeOnLAN {
#[async_trait] #[async_trait]
impl traits::Scene for WakeOnLAN { impl traits::Scene for WakeOnLAN {
async fn set_active(&mut self, activate: bool) -> Result<(), ErrorCode> { async fn set_active(&mut self, deactivate: bool) -> Result<(), ErrorCode> {
if activate { 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!( debug!(
id = Device::get_id(self), id = Device::get_id(self),
"Activating Computer: {} (Sending to {})", "Activating Computer: {} (Sending to {})",
@ -131,15 +140,6 @@ impl traits::Scene for WakeOnLAN {
google_home::errors::DeviceError::TransientError.into() google_home::errors::DeviceError::TransientError.into()
}) })
.map(|_| debug!(id = Device::get_id(self), "Success!")) .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,
))
} }
} }
} }