From 476688e3cb895765aea1d62570723ebe82a828dd Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Tue, 5 Mar 2024 20:06:00 +0100 Subject: [PATCH] Always turn all the lights on when a contact sensor is activated, not matter the previous state --- src/devices/contact_sensor.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/devices/contact_sensor.rs b/src/devices/contact_sensor.rs index 8b503e3..3fba893 100644 --- a/src/devices/contact_sensor.rs +++ b/src/devices/contact_sensor.rs @@ -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::::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 {