Update
This commit is contained in:
parent
bf688bf7f8
commit
3a2a6146b6
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "c3c-knx-presence",
|
||||
"version": "0.0.223",
|
||||
"version": "0.0.228",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "c3c-knx-presence",
|
||||
"version": "0.0.223",
|
||||
"version": "0.0.228",
|
||||
"hasInstallScript": true,
|
||||
"license": "GPL-3.0-only",
|
||||
"devDependencies": {
|
||||
|
||||
@ -35,5 +35,5 @@
|
||||
"postinstall": "npm run install-control4-utils && npm run driver-manager",
|
||||
"test": "busted tests/test.lua"
|
||||
},
|
||||
"version": "0.0.223"
|
||||
"version": "0.0.228"
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
(function()
|
||||
local disable = false
|
||||
local present = false
|
||||
local lux = 70
|
||||
|
||||
local mediaPlaying = false
|
||||
local mediaOverridden = false
|
||||
@ -32,7 +33,7 @@
|
||||
C3C.Logger.Debug("Resetting media override after 120 seconds", ctx)
|
||||
mediaOverridden = false
|
||||
end
|
||||
end, "checkMediaOverride")
|
||||
end, "UFBathroomCheckMediaOverride")
|
||||
end
|
||||
|
||||
local overrideLight = function(ga)
|
||||
@ -49,7 +50,7 @@
|
||||
C3C.Logger.Debug("Resetting light override after 120 seconds", ctx)
|
||||
lightOverridden = false
|
||||
end
|
||||
end, "checkLightOverride")
|
||||
end, "UFBathroomCheckLightOverride")
|
||||
end
|
||||
|
||||
local unOverrideMedia = function()
|
||||
@ -68,6 +69,10 @@
|
||||
mediaPlaying = ga.Value == 1
|
||||
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 Preset Cycle Forward", 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("UF Bathroom Exit", function()
|
||||
C3C.OneShotTimer.Add(2000, function()
|
||||
unOverrideMedia()
|
||||
unOverrideLight()
|
||||
end, "UFBathroomExit")
|
||||
end)
|
||||
|
||||
|
||||
@ -102,6 +109,7 @@
|
||||
present = true
|
||||
|
||||
local ctx = createContext("presenceStart")
|
||||
ctx.lux = lux
|
||||
C3C.Logger.Debug("Triggered: Presence start", ctx)
|
||||
|
||||
if disable then
|
||||
@ -110,14 +118,19 @@
|
||||
end
|
||||
|
||||
time = os.date("*t")
|
||||
|
||||
if 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)
|
||||
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
|
||||
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)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
C3C.Logger.Debug("Firing event: UpperFloorBathroomMediaStart", ctx)
|
||||
C4:FireEvent("UpperFloorBathroomMediaStart")
|
||||
@ -130,14 +143,20 @@
|
||||
C3C.Logger.Debug("Triggered: Presence end", ctx)
|
||||
|
||||
if not lightOverridden then
|
||||
if gaPrimaryLightCTRLFB.Value ~ 0 then
|
||||
if gaPrimaryLightCTRLFB.Value ~= 0 then
|
||||
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 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
|
||||
|
||||
if gaAmbientLightCTRLFB.Value ~= 0 then
|
||||
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 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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user