-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathwakeup_dead_nodes.lua
48 lines (40 loc) · 1.17 KB
/
wakeup_dead_nodes.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
45
46
47
48
--[[
%% properties
%% autostart
%% globals
--]]
local TotalDevices = 300 --max nr of devices
while true do
local timeNow = os.date('*t')
local day = timeNow['day']
local month = timeNow['month']
local i = 1
local anydead = 0
while i < TotalDevices do
--check if any dead
local status = fibaro:getValue(i, 'dead');
local name = fibaro:getName(i);
local room = fibaro:getRoomNameByDeviceID(i);
if status >= "1" then
fibaro:debug(day.."/"..month..":"..i..' DEAD '..name..":"..room);
fibaro:wakeUpDeadDevice(i)
fibaro:sleep(5000) --check again in 5 sec
status = fibaro:getValue(i, 'dead');
if status >= "1" then
anydead = 1; fibaro:debug('Really Dead')
else
fibaro:debug('Now OK '..name)
end
end
i = i + 1
end
if anydead == 0 then
--fibaro:debug('Nobody is dead :-) ')
else
fibaro:call(2, 'sendEmail', 'Somebody really DEAD', '..')
fibaro:debug('Somebody really DEAD')
end
-- abort any unnecesary scenes started
if fibaro:countScenes() > 1 then fibaro:abort() end
fibaro:sleep(15*60000) --repeat every 15 minutes
end