-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSunrise.lua
More file actions
41 lines (36 loc) · 1.46 KB
/
Sunrise.lua
File metadata and controls
41 lines (36 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
return {
on = {
timer = { 'every minute' }
},
logging = {
level = domoticz.LOG_FORCE,
marker = "Sunrise"
},
data = {
sunriseLevel = { initial = 0 }
},
execute = function(domoticz, timer)
local switch = domoticz.devices('Start Sunrise')
local light = domoticz.devices('YeeLight LED (Stripe)')
domoticz.data.sunriseLevel = domoticz.data.sunriseLevel + 5
domoticz.log('Tick '..tostring(switch.active).." "..tostring(light.active).." "..tostring(light.level), LOG_DEBUG)
if (switch.active) then
domoticz.log('brightnes is '..domoticz.data.sunriseLevel, LOG_DEBUG)
domoticz.data.sunriseLevel = domoticz.data.sunriseLevel + 5
if (not light.active and domoticz.data.sunriseLevel == 0) then
domoticz.log('Wake UP Light', LOG_FORCE)
light.switchOn()
end
if (domoticz.data.sunriseLevel <= 255) then
light.setColor(domoticz.data.sunriseLevel, domoticz.data.sunriseLevel / 2, 0)
elseif (domoticz.data.sunriseLevel <= 500) then
light.setColor(255, 125 + domoticz.data.sunriseLevel / 4, domoticz.data.sunriseLevel - 255)
else
switch.switchOff().checkFirst()
domoticz.data.sunriseLevel = 0
end
else
domoticz.data.sunriseLevel = 0
end
end
}