Je viens vers vous, j'ai mis le script suivant en place
Code : Tout sélectionner
-- Meteo France vigilance from domogeek API
-- domoticz/scripts/lua/script_time_vigilance.lua
-- Information from Meteo France is updated everyday at 6AM and 5PM
-- This script will check at 6.10AM and 5.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 17:10
if (time.min == 10 and ((time.hour == 6) or (time.hour == 17))) then
-- Path to curl
local curl = '/usr/bin/curl'
-- Device ID (Type Alert on virtual hardware)
local idx = '394'
-- Department (France)
local dept = '72'
local cmd = 'curl http://domogeek.entropialux.com/vigilance/' .. dept..'/all'
local vigilance = os.capture(cmd, true)
local fill1 = nil
local fill2 = nil
local fill3 = nil
local flood = nil
local color = nil
local risk = nil
fill1, flood, fill2, color, fill3, risk = string.match(vigilance,"{\"(.-)\": \"(.-)\", \"(.-)\": \"(.-)\", \"(.-)\": \"(.-)\"}$")
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 commandArrayFaut il faire autre chose car le capteur ne se met pas a jour ?
merci de votre aide