-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gradually turn on a light in the morning to wake you up naturally
Set a time you want to wake up and the script will slowly fade up your light to simulate sun rise in your room.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--[[ | ||
%% autostart | ||
%% properties | ||
%% globals | ||
--]] | ||
|
||
while true do | ||
|
||
local currentDate = os.date("*t"); | ||
local wakeuptime = "07:45"; -- time to wake up | ||
local startlevel = 20; -- start dim level | ||
local dimlevel; | ||
local maxlevel = 100; -- max dim level | ||
local diminterval = 1; -- interval time in minutes to wait to next dimlevel | ||
local levelsteps = 10; -- steps in procent to increase dim level | ||
local light = 26; -- light to control | ||
local debug = true; | ||
|
||
if (maxlevel > 100) then maxlevel = 100; end | ||
if (startlevel > maxlevel) then startlevel = maxlevel; end | ||
|
||
if ( ( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == wakeuptime) ) ) | ||
then | ||
fibaro:debug("Wake up started at: " .. os.date()); | ||
for level = startlevel, maxlevel, levelsteps do | ||
dimlevel = level; | ||
if (dimlevel > 100) then dimlevel = 100; end | ||
fibaro:call(light, "setValue", dimlevel); | ||
if (debug) then fibaro:debug("Set dim level at: " .. os.date()); end | ||
if (debug) then fibaro:debug("Dimlevel: " .. dimlevel); end | ||
fibaro:sleep(diminterval*60*1000); | ||
end | ||
end | ||
|
||
fibaro:sleep(60*1000); | ||
end |