Fix: contact sensor turns off lights even if they were already on
All checks were successful
Build and deploy automation_rs / Build automation_rs (push) Successful in 3m57s
Build and deploy automation_rs / Build Docker image (push) Successful in 45s
Build and deploy automation_rs / Deploy Docker container (push) Successful in 29s

This commit is contained in:
Dreaded_X 2024-04-26 06:00:53 +02:00
parent 8b0c1ae352
commit 40ba4c47cf
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4

View File

@ -159,9 +159,10 @@ impl OnMqtt for ContactSensor {
if let Some(trigger) = &mut self.trigger {
if !self.is_closed {
for (light, _) in &mut trigger.devices {
for (light, previous) 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();
light.set_on(true).await.ok();
}
}