first commit
This commit is contained in:
51
lua/old/script_time_Vigilance.old
Executable file
51
lua/old/script_time_Vigilance.old
Executable file
@@ -0,0 +1,51 @@
|
||||
--curl http://domogeek.entropialux.com/vigilance/56/
|
||||
|
||||
require "scripts/lua/functions"
|
||||
|
||||
--recupere les minutes
|
||||
time=os.time()
|
||||
minutes=tonumber(os.date('%M',time))
|
||||
heures=tonumber(os.date('%H',time))
|
||||
|
||||
commandArray = {}
|
||||
|
||||
-- Function to update a switch
|
||||
function updateVigilance(zone, idx)
|
||||
local cmd = "curl -y 1 http://domogeek.entropialux.com/vigilance/"..zone.."/color"
|
||||
local vac = os.capture(cmd, true)
|
||||
|
||||
local level = 0
|
||||
if (vac == "rouge") then level = 4 end
|
||||
if (vac == "orange") then level = 3 end
|
||||
if (vac == "jaune") then level = 2 end
|
||||
if (vac == "vert") then level = 1 end
|
||||
|
||||
if (level >= 3 or (level == 2 and heures == 18)) then
|
||||
--local html = os.capture("curl \"http://vigilance.meteofrance.com/Bulletin_sans.html?a=dept44&b=2&c=\"", true)
|
||||
commandArray['SendNotification']='Alerte Vigilance '..vac..'#Attention alerte vigilance '..vac..' sur le '..zone..' \nhttp://vigilance.meteofrance.com/\n#0'
|
||||
end
|
||||
|
||||
debug("Sunset" .. cmd .. ": "..vac..' Level '..level)
|
||||
commandArray['UpdateDevice']=idx..'|'..level..'|Niveau de vigilance '..vac..' Departement '..zone
|
||||
end
|
||||
|
||||
|
||||
time = os.date("*t")
|
||||
|
||||
-- local cmd = "curl http://domogeek.entropialux.com/vigilance/56/all"
|
||||
-- local vac = os.capture(cmd, true)
|
||||
-- print(vac)
|
||||
-- Trigger at 0:03 every day
|
||||
if (time.hour == 0 or time.hour == 6 or time.hour == 12 or time.hour == 18) then
|
||||
if time.min == 1 then
|
||||
updateVigilance("56", "185")
|
||||
end
|
||||
if time.min == 2 then
|
||||
updateVigilance("44", "315")
|
||||
end
|
||||
if time.min == 3 then
|
||||
updateVigilance("35", "314")
|
||||
end
|
||||
end
|
||||
|
||||
return commandArray
|
||||
Reference in New Issue
Block a user