From d4fe451788d14e5690f45b0b969cf280088e4b83 Mon Sep 17 00:00:00 2001 From: Arnie Date: Wed, 29 Jul 2026 08:21:05 +0200 Subject: [PATCH] Fix presence with overrides --- src/driver.xml | 2 +- src/lib/presence/UF/Bathroom.lua | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/driver.xml b/src/driver.xml index 95b6cf2..3a61ad0 100644 --- a/src/driver.xml +++ b/src/driver.xml @@ -6,7 +6,7 @@ c3c-knx-presence 2023-05-14 2026-07-04 - 233 + 234 false lua_gen KNX diff --git a/src/lib/presence/UF/Bathroom.lua b/src/lib/presence/UF/Bathroom.lua index 432953f..d48872b 100644 --- a/src/lib/presence/UF/Bathroom.lua +++ b/src/lib/presence/UF/Bathroom.lua @@ -119,7 +119,9 @@ time = os.date("*t") - if lux < 50 then + if lightOverridden then + C3C.Logger.Debug("Light overridden, skipping automatic light control", ctx) + elseif lux < 50 then if C3C.Lib.State.DayTime.IsDay() or (time.hour >= 7 and time.hour <= 19) then C3C.Logger.Debug("Switching on primary light", ctx) C3C.KnxAddresses.Get("Switch UF Bathroom Primary CTRL"):Send(1) @@ -134,8 +136,12 @@ end end - C3C.Logger.Debug("Firing event: UpperFloorBathroomMediaStart", ctx) - C4:FireEvent("UpperFloorBathroomMediaStart") + if mediaOverridden then + C3C.Logger.Debug("Media overridden, skipping media start event", ctx) + else + C3C.Logger.Debug("Firing event: UpperFloorBathroomMediaStart", ctx) + C4:FireEvent("UpperFloorBathroomMediaStart") + end end local presenceEnd = function() @@ -166,9 +172,6 @@ C3C.Logger.Debug("Firing event: UpperFloorBathroomMediaEnd", ctx) C4:FireEvent("UpperFloorBathroomMediaEnd") end - - unOverrideMedia() - unOverrideLight() end local presenceEndDelayed = function() @@ -186,6 +189,9 @@ C3C.Logger.Debug("Switching off ambient light", ctx) C3C.KnxAddresses.Get("Switch UF Bathroom Ambient CTRL"):Send(0) end + + unOverrideMedia() + unOverrideLight() end C3C.KnxAddresses.Watch("Control UF Bathroom Presence", function(ga, state)