Improved long press behaviour when there is no long press callback
All checks were successful
Build and deploy / Build application (push) Successful in 3m23s
Build and deploy / Build container (push) Successful in 52s
Build and deploy / Deploy container (push) Successful in 47s

This commit is contained in:
Dreaded_X 2025-01-29 00:55:00 +01:00
parent 00cd0366fd
commit d9e83a49a1
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
2 changed files with 16 additions and 1 deletions

View File

@ -95,9 +95,20 @@ impl OnMqtt for HueSwitch {
match action { match action {
Action::LeftPressRelease => self.config.left_callback.call(self, &()).await, Action::LeftPressRelease => self.config.left_callback.call(self, &()).await,
Action::LeftHold => self.config.left_hold_callback.call(self, &()).await,
Action::RightPressRelease => self.config.right_callback.call(self, &()).await, Action::RightPressRelease => self.config.right_callback.call(self, &()).await,
Action::LeftHold => self.config.left_hold_callback.call(self, &()).await,
Action::RightHold => self.config.right_hold_callback.call(self, &()).await, Action::RightHold => self.config.right_hold_callback.call(self, &()).await,
// If there is no hold action, the switch will act like a normal release
Action::RightHoldRelease => {
if !self.config.right_hold_callback.is_set() {
self.config.right_callback.call(self, &()).await
}
}
Action::LeftHoldRelease => {
if !self.config.left_hold_callback.is_set() {
self.config.left_callback.call(self, &()).await
}
}
_ => {} _ => {}
} }
} }

View File

@ -64,4 +64,8 @@ where
_ => todo!("Only functions are currently supported"), _ => todo!("Only functions are currently supported"),
} }
} }
pub fn is_set(&self) -> bool {
self.internal.is_some()
}
} }