-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path223. Report and fix Dead Nodes
83 lines (69 loc) · 2.04 KB
/
223. Report and fix Dead Nodes
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--[[
%% autostart
%% properties
%% events
%% globals
RunClock
--]]
local startSource = fibaro:getSourceTrigger();
if (
( fibaro:getGlobalValue("RunClock") == "Ja" )
or
startSource["type"] == "other"
)
then
-- Code is based on script from Mike Carter, budda
-- added fix for removed devices
local TotalDevices = 1000 --max nr of devices
while true do
local timeNow = os.date('*t')
local day = timeNow['day']
local month = timeNow['month']
local d_status = "ok"
local i = 1
local anydead = 0
while i < TotalDevices do
--check if any dead
local status = fibaro:getValue(i, 'dead');
if status ~= nil then
if status >= "1" then
local d_status = "dead"
else
local d_status = "ok"
end
local name = fibaro:getName(i);
local room = fibaro:getRoomNameByDeviceID(i);
-- fibaro:debug(i.." "..name.." "..room.." "..d_status);
if status >= "1" then
local melding = (day.."/"..month..":"..i..' DEAD, trying to re-start '..name..":"..room);
fibaro:debug(melding);
--fibaro:call(448,'sendPush', melding);
fibaro:call(i, "wakeUpDeadDevice")
fibaro:sleep(50000) --check again in 50 sec
status = fibaro:getValue(i, 'dead');
if status >= "1" then
anydead = 1;
local melding = (day.."/"..month..":"..i..' DEAD, re-start failed '..name..":"..room);
fibaro:debug(melding)
fibaro:call(710,'sendPush', melding);
else
local melding = (day.."/"..month..":"..i..' succeeded restart '..name..":"..room);
fibaro:debug(melding)
--fibaro:call(710,'sendPush', melding);
end
else
end
end
i = i + 1
end
if anydead == 0 then
--fibaro:debug('Nobody is dead :-) ')
else
fibaro:debug('A device is really DEAD')
fibaro:call(2, "sendEmail", "Fibaro device is dead", melding); -- Mail Hans Olav
end
-- abort any unnecesary scenes started
if fibaro:countScenes() > 1 then fibaro:abort() end
fibaro:sleep(15*60000) --repeat every 60 minutes
end
end