Bonjour,
J'ai repris le script lua de hobbe. J'avais mis volontairement mon panneau d'alerte sur rouge pour voir si le script le mettrait bien a jour. Mon script s'est bien déclenché à 6h10 comme indiqué dans le script mais mon panneau est devenu gris (level 0). J'ai repris le script en modifiant juste l'idx de mon alerte (36) et en modifiant mon département (64). Quelqu'un peut me dire où je me plante svp??? (voir script ci-dessous)
-- Meteo France vigilance from domogeek API
-- domoticz/scripts/lua/script_time_vigilance.lua
-- Information from Meteo France is updated everyday at 6AM and 4PM
-- This script will check at 6.10AM and 4.10PM
function os.capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
commandArray = {}
time = os.date("*t")
-- Trigger at 6:10 and 16:10
if (time.min == 10 and ((time.hour == 6) or (time.hour == 16))) then
-- Path to curl
local curl = 'C:\\bin\\curl.exe'
-- Device ID (Type Alert on virtual hardware)
local idx = '36'
-- Department (France)
local dept = '64'
local cmd = curl .. '
http://api.domogeek.fr/vigilance/' .. dept
local color = os.capture(cmd .. '/color', true);
local risk = os.capture(cmd .. '/risk', true);
print('Vigilance: ' .. cmd .. ': ' .. color .. ' / ' .. risk)
local sValue = 'Risque : ' .. risk
local nValue = 0
if color == "vert" then nValue = 1
elseif color == "jaune" then nValue = 2
elseif color == "orange" then nValue = 3
elseif color == "rouge" then nValue = 4
else nValue = 0
end
-- Update device idx with nValue and sValue
commandArray['UpdateDevice'] = idx .. '|' .. nValue .. '|' .. sValue
end
return commandArray