Always turn all the lights on when a contact sensor is activated, not matter the previous state
All checks were successful
Build and deploy automation_rs / Build automation_rs (push) Successful in 7m25s
Build and deploy automation_rs / Build Docker image (push) Successful in 2m45s
Build and deploy automation_rs / Deploy Docker container (push) Successful in 37s

This commit is contained in:
Dreaded_X 2024-03-05 20:06:00 +01:00
parent 6e4a63e9d7
commit 476688e3cb
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4

View File

@ -159,17 +159,10 @@ impl OnMqtt for ContactSensor {
if let Some(trigger) = &mut self.trigger {
if !self.is_closed {
for (light, previous) in &mut trigger.devices {
for (light, _) in &mut trigger.devices {
let mut light = light.write().await;
if let Some(light) = As::<dyn OnOff>::cast_mut(light.as_mut()) {
*previous = light.is_on().await.unwrap();
// Only turn the light on when it is currently off
// This is done such that if the light is on but dimmed for example it
// won't suddenly blast at full brightness but instead retain the current
// state
if !*previous {
light.set_on(true).await.ok();
}
light.set_on(true).await.ok();
}
}
} else {