-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTurn-Off-All-Lights.lua
44 lines (34 loc) · 1.01 KB
/
Turn-Off-All-Lights.lua
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
42
43
44
--[[
%% autostart
%% properties
%% globals
--]]
NB_DEVICES = 300
function turnAllOff()
fibaro:debug('Turn all devices off.')
-- Turn off all devices
for i = 1, NB_DEVICES do
fibaro:call(i, "turnOff");
end
end
local sourceTrigger = fibaro:getSourceTrigger();
if (sourceTrigger["type"] == "autostart") then
while true do
fibaro:debug('Scene automatically called.')
local currentDate = os.date("*t");
-- Turn off devices only Monday-Saturday between 19:00 and 19:10
if ((currentDate.wday >= 2 and currentDate.wday <= 7) and (currentDate.hour == 19 ) and (currentDate.min > 0 and currentDate.min < 10))
then
fibaro:debug('Lights automatically switched off.')
turnAllOff()
end
fibaro:sleep(5*60000); -- Run every 5 minutes
end
else
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (startSource["type"] == "other")
then
turnAllOff()
end
end