This commit is contained in:
Arnie 2025-11-09 20:28:48 +01:00
parent bf688bf7f8
commit 3a2a6146b6
Signed by: arnie
GPG Key ID: 59315333892F43F4
3 changed files with 34 additions and 15 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "c3c-knx-presence", "name": "c3c-knx-presence",
"version": "0.0.223", "version": "0.0.228",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "c3c-knx-presence", "name": "c3c-knx-presence",
"version": "0.0.223", "version": "0.0.228",
"hasInstallScript": true, "hasInstallScript": true,
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"devDependencies": { "devDependencies": {

View File

@ -35,5 +35,5 @@
"postinstall": "npm run install-control4-utils && npm run driver-manager", "postinstall": "npm run install-control4-utils && npm run driver-manager",
"test": "busted tests/test.lua" "test": "busted tests/test.lua"
}, },
"version": "0.0.223" "version": "0.0.228"
} }

View File

@ -1,6 +1,7 @@
(function() (function()
local disable = false local disable = false
local present = false local present = false
local lux = 70
local mediaPlaying = false local mediaPlaying = false
local mediaOverridden = false local mediaOverridden = false
@ -32,7 +33,7 @@
C3C.Logger.Debug("Resetting media override after 120 seconds", ctx) C3C.Logger.Debug("Resetting media override after 120 seconds", ctx)
mediaOverridden = false mediaOverridden = false
end end
end, "checkMediaOverride") end, "UFBathroomCheckMediaOverride")
end end
local overrideLight = function(ga) local overrideLight = function(ga)
@ -49,7 +50,7 @@
C3C.Logger.Debug("Resetting light override after 120 seconds", ctx) C3C.Logger.Debug("Resetting light override after 120 seconds", ctx)
lightOverridden = false lightOverridden = false
end end
end, "checkLightOverride") end, "UFBathroomCheckLightOverride")
end end
local unOverrideMedia = function() local unOverrideMedia = function()
@ -68,6 +69,10 @@
mediaPlaying = ga.Value == 1 mediaPlaying = ga.Value == 1
end) end)
C3C.KnxAddresses.Watch("Control UF Bathroom Brightness", function(ga)
lux = ga.Value
end)
C3C.KnxAddresses.Watch("Media UF Bathroom Off", overrideMedia) C3C.KnxAddresses.Watch("Media UF Bathroom Off", overrideMedia)
C3C.KnxAddresses.Watch("Media UF Bathroom Preset Cycle Forward", overrideMedia) C3C.KnxAddresses.Watch("Media UF Bathroom Preset Cycle Forward", overrideMedia)
C3C.KnxAddresses.Watch("Media UF Bathroom Volume Up", overrideMedia) C3C.KnxAddresses.Watch("Media UF Bathroom Volume Up", overrideMedia)
@ -93,8 +98,10 @@
C3C.KnxAddresses.Watch("Dimmer UF Bathroom Ambient Dimming", overrideLight) C3C.KnxAddresses.Watch("Dimmer UF Bathroom Ambient Dimming", overrideLight)
C3C.KnxAddresses.Watch("UF Bathroom Exit", function() C3C.KnxAddresses.Watch("UF Bathroom Exit", function()
C3C.OneShotTimer.Add(2000, function()
unOverrideMedia() unOverrideMedia()
unOverrideLight() unOverrideLight()
end, "UFBathroomExit")
end) end)
@ -102,6 +109,7 @@
present = true present = true
local ctx = createContext("presenceStart") local ctx = createContext("presenceStart")
ctx.lux = lux
C3C.Logger.Debug("Triggered: Presence start", ctx) C3C.Logger.Debug("Triggered: Presence start", ctx)
if disable then if disable then
@ -110,14 +118,19 @@
end end
time = os.date("*t") time = os.date("*t")
if lux < 50 then
if C3C.Lib.State.DayTime.IsDay() or (time.hour >= 7 and time.hour <= 19) 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.Logger.Debug("Switching on primary light", ctx)
C3C.KnxAddresses.Get("Switch UF Bathroom Primary CTRL"):Send(1) C3C.KnxAddresses.Get("Switch UF Bathroom Primary CTRL"):Send(1)
C3C.KnxAddresses.Get("Switch UF Bathroom Primary Light 1"):Send(1)
C3C.KnxAddresses.Get("Switch UF Bathroom Primary Light 2"):Send(1)
elseif time.hour > 19 and time.hour <= 20 then elseif time.hour > 19 and time.hour <= 20 then
C3C.Logger.Debug("Switching on primary light with dimmed control during nighttime", ctx) C3C.Logger.Debug("Switching on primary light with dimmed control during nighttime", ctx)
C3C.KnxAddresses.Get("Switch UF Bathroom Primary CTRL"):Send(1)
C3C.KnxAddresses.Get("Dimmer UF Bathroom Primary"):Send(12) C3C.KnxAddresses.Get("Dimmer UF Bathroom Primary"):Send(12)
end end
end
C3C.Logger.Debug("Firing event: UpperFloorBathroomMediaStart", ctx) C3C.Logger.Debug("Firing event: UpperFloorBathroomMediaStart", ctx)
C4:FireEvent("UpperFloorBathroomMediaStart") C4:FireEvent("UpperFloorBathroomMediaStart")
@ -130,14 +143,20 @@
C3C.Logger.Debug("Triggered: Presence end", ctx) C3C.Logger.Debug("Triggered: Presence end", ctx)
if not lightOverridden then if not lightOverridden then
if gaPrimaryLightCTRLFB.Value ~ 0 then if gaPrimaryLightCTRLFB.Value ~= 0 then
C3C.Logger.Debug("Switching off primary light", ctx) C3C.Logger.Debug("Switching off primary light", ctx)
C3C.KnxAddresses.Get("Switch UF Bathroom Primary CTRL"):Send(0) C3C.KnxAddresses.Get("Switch UF Bathroom Primary CTRL"):Send(0)
C3C.KnxAddresses.Get("Switch UF Bathroom Primary Light 1"):Send(0)
C3C.KnxAddresses.Get("Switch UF Bathroom Primary Light 2"):Send(0)
C3C.KnxAddresses.Get("Switch UF Bathroom Primary Light Vanity"):Send(0)
end end
if gaAmbientLightCTRLFB.Value ~= 0 then if gaAmbientLightCTRLFB.Value ~= 0 then
C3C.Logger.Debug("Switching off ambient light", ctx) C3C.Logger.Debug("Switching off ambient light", ctx)
C3C.KnxAddresses.Get("Switch UF Bathroom Ambient CTRL"):Send(0) C3C.KnxAddresses.Get("Switch UF Bathroom Ambient CTRL"):Send(0)
C3C.KnxAddresses.Get("Switch UF Bathroom Ambient Light 1"):Send(0)
C3C.KnxAddresses.Get("Switch UF Bathroom Ambient Light 2"):Send(0)
C3C.KnxAddresses.Get("Switch UF Bathroom Ambient Toilet"):Send(0)
end end
end end