Merci pour le retour !Lou Castelou a écrit :Super ton script sur le suivi des cours d'eau. Mise en place facile et restitution nickel.
Pas de chance en ce qui me concerne, ma station concernée (L870001010) ne délivre pas le débit.
Bonne journée.

Merci pour le retour !Lou Castelou a écrit :Super ton script sur le suivi des cours d'eau. Mise en place facile et restitution nickel.
Pas de chance en ce qui me concerne, ma station concernée (L870001010) ne délivre pas le débit.
Bonne journée.
Bonjour et bonne année égalementchatainsim a écrit :Bonne année.balajol a écrit :Bonsoir Chatainsim,
Pour ma suggestion, personnellement je pense que la hauteur d'eau est ce qui intéresse les personnes à proximité d'une rivière.
Par "Expérience" en général elles savent à partir de quel niveau elles auront "les pieds dans l' eau "
La surveillance du débit peut être une donnée pour une pré Alarme, surtout la vitesse à laquelle il augmente.
Pour le fichier Json, mes connaissances en Lua et consorts ne sont pas au niveau des tiennes,
Il faut que je gratte un Peu (beaucoup) Pour comprendre ta question![]()
Pour ce qui concerne la réalisation de cette modif, il n'y a bien entendu aucune urgence, avoir accès aux info directement dans DOMOTICZ est déjà pas mal .
Cdt
Bertrand
Je n'ai pas abandonné le script mais je suis encore en congés. (Non je ne suis pas prof)
Je regarde ça la semaine prochaine.
Tout à fait d'accord pour les profs !balajol a écrit :
Bonjour et bonne année également
Aucune honte à avoir pour les profs,il en faut.
Le scipt fonctionne parfaitement depuis.
Au plaisir de te lire
Bertrand
Code : Tout sélectionner
-- Parameters to change according to you needs
debug=false
-- Json config loadfile
config = 'C:/Program Files (x86)/Domoticz/scripts/lua/vigicrue.json'--'/opt/domoticz/scripts/vigicrue.json'
-- JSON.lua path
--json = (loadfile "/opt/domoticz/scripts/lua/JSON.lua")()
json = (loadfile "C:/Program Files (x86)/Domoticz/scripts/lua/JSON.lua")()
-- Curl path
curl = 'C:/curl-7.50.3-win32-mingw/bin/curl.exe '--'/usr/bin/curl'
-- End of parameters
time = os.date("*t")
n=1
-- Function to update sensor
local function update(idx, value1)
local cmd = idx..'|0|'..value1
--print(cmd)
table.insert (commandArray, { ['UpdateDevice'] = cmd } )
end
-- function to get data from url
local function getdata(urlh,urls)
local DataHeight = assert(io.popen(curl..' -s "'..urlh..'"')) --local DataHeight = assert(io.popen('C:/curl-7.50.3-win32-mingw/bin/curl.exe "'..urlh..'"')) -- lien du Premier scipt fonctionnel
local BlocJsonHeight = DataHeight:read('*all')
DataHeight:close()
local JsonHeight = json:decode(BlocJsonHeight)
local Height = JsonHeight.Serie.ObssHydro
local Name = JsonHeight.Serie.LbStationHydro
local DataSpeed = assert(io.popen(curl..' -s "'..urls..'"')) --local DataSpeed = assert(io.popen('C:/curl-7.50.3-win32-mingw/bin/curl.exe "'..urls..'"'))
local BlocJsonSpeed = DataSpeed:read('*all')
DataSpeed:close()
local JsonSpeed = json:decode(BlocJsonSpeed)
local Speed = JsonSpeed.Serie.ObssHydro
return Height, Speed, Name
end
commandArray = {}
if ( time.min%1 == 0 ) then--Lancement Script toutes les 1 minutes
--if (time.min == 5 or time.min == 30) then
local file = assert(io.open(config, "r"))
local json_text = file:read("*all")
file:close()
local Conf = json:decode(json_text)
Station = Conf.station
for k,v in pairs(Station) do
print("V is: "..v)
local IDStation = v
local IDXHeight = Conf.idx.height[v]
local IDXSpeed = Conf.idx.speed[v]
local NotifHeightV = Conf.notifications.height[v].value
local NotifHeightA = Conf.notifications.height[v].active
local NotifSpeedV = Conf.notifications.speed[v].value
local NotifSpeedA = Conf.notifications.speed[v].active
local urlHeight = 'https://www.vigicrues.gouv.fr/services/observations.json/index.php?CdStationHydro='..IDStation..'&GrdSerie=H&FormatSortie=simple'
local urlSpeed = 'https://www.vigicrues.gouv.fr/services/observations.json/index.php?CdStationHydro='..IDStation..'&GrdSerie=Q&FormatSortie=simple'
ResultHeight,ResultSpeed,StationName=getdata(urlHeight,urlSpeed)
print("IDX Height: "..IDXHeight)
print("IDX Speed: "..IDXSpeed)
if (#ResultHeight ~= 0) then
if (debug) then print("ResultHeight: "..ResultHeight[#ResultHeight][2]) end
update(IDXHeight, ResultHeight[#ResultHeight][2])
if (NotifHeightA) then
if (tostring(ResultHeight[#ResultHeight][2]) > NotifHeightV) then
commandArray[n]={['SendNotification']='Water level is high for station '..StationName..'#Current level is '..ResultHeight[#ResultHeight][2]..'m for '..StationName..'#0#sound#extradata#telegram'}
n=n+1
end
end
else
if (debug) then print('Height level is empty.') end
end
if (#ResultSpeed ~= 0) then
if (debug) then print("ResultSpeed: "..ResultSpeed[#ResultSpeed][2]) end
update(IDXSpeed, ResultSpeed[#ResultSpeed][2])
if (NotifSpeedA) then
if (tostring(ResultSpeed[#ResultSpeed][2]) > NotifSpeedV) then
commandArray[n]={['SendNotification']='Water speed level is high for station '..StationName..'#Current speed level: '..ResultSpeed[#ResultSpeed][2]..'m3/s for '..StationName..'#0#sound#extradata#telegram'}
n=n+1
end
end
else
if (debug) then print('Speed is empty.') end
end
end
end
return commandArray
Normalement tu n'a besoin de définir le chemin de curl qu'au début :balajol a écrit :Re,
A priori les devices ne se mettent pas à jour sous Windows
Je pense problème syntaxe pour l'appel Json et curl
Pas de message d'erreur: Je n'avais pas remarqué dans la version Préçédente qu'avec:Code : Tout sélectionner
-- Parameters to change according to you needs debug=false -- Json config loadfile config = 'C:/Program Files (x86)/Domoticz/scripts/lua/vigicrue.json'--'/opt/domoticz/scripts/vigicrue.json' -- JSON.lua path --json = (loadfile "/opt/domoticz/scripts/lua/JSON.lua")() json = (loadfile "C:/Program Files (x86)/Domoticz/scripts/lua/JSON.lua")() -- Curl path curl = 'C:/curl-7.50.3-win32-mingw/bin/curl.exe '--'/usr/bin/curl' -- End of parameters time = os.date("*t") n=1 -- Function to update sensor local function update(idx, value1) local cmd = idx..'|0|'..value1 --print(cmd) table.insert (commandArray, { ['UpdateDevice'] = cmd } ) end -- function to get data from url local function getdata(urlh,urls) local DataHeight = assert(io.popen(curl..' -s "'..urlh..'"')) --local DataHeight = assert(io.popen('C:/curl-7.50.3-win32-mingw/bin/curl.exe "'..urlh..'"')) -- lien du Premier scipt fonctionnel local BlocJsonHeight = DataHeight:read('*all') DataHeight:close() local JsonHeight = json:decode(BlocJsonHeight) local Height = JsonHeight.Serie.ObssHydro local Name = JsonHeight.Serie.LbStationHydro local DataSpeed = assert(io.popen(curl..' -s "'..urls..'"')) --local DataSpeed = assert(io.popen('C:/curl-7.50.3-win32-mingw/bin/curl.exe "'..urls..'"')) local BlocJsonSpeed = DataSpeed:read('*all') DataSpeed:close() local JsonSpeed = json:decode(BlocJsonSpeed) local Speed = JsonSpeed.Serie.ObssHydro return Height, Speed, Name end commandArray = {} if ( time.min%1 == 0 ) then--Lancement Script toutes les 1 minutes --if (time.min == 5 or time.min == 30) then local file = assert(io.open(config, "r")) local json_text = file:read("*all") file:close() local Conf = json:decode(json_text) Station = Conf.station for k,v in pairs(Station) do print("V is: "..v) local IDStation = v local IDXHeight = Conf.idx.height[v] local IDXSpeed = Conf.idx.speed[v] local NotifHeightV = Conf.notifications.height[v].value local NotifHeightA = Conf.notifications.height[v].active local NotifSpeedV = Conf.notifications.speed[v].value local NotifSpeedA = Conf.notifications.speed[v].active local urlHeight = 'https://www.vigicrues.gouv.fr/services/observations.json/index.php?CdStationHydro='..IDStation..'&GrdSerie=H&FormatSortie=simple' local urlSpeed = 'https://www.vigicrues.gouv.fr/services/observations.json/index.php?CdStationHydro='..IDStation..'&GrdSerie=Q&FormatSortie=simple' ResultHeight,ResultSpeed,StationName=getdata(urlHeight,urlSpeed) print("IDX Height: "..IDXHeight) print("IDX Speed: "..IDXSpeed) if (#ResultHeight ~= 0) then if (debug) then print("ResultHeight: "..ResultHeight[#ResultHeight][2]) end update(IDXHeight, ResultHeight[#ResultHeight][2]) if (NotifHeightA) then if (tostring(ResultHeight[#ResultHeight][2]) > NotifHeightV) then commandArray[n]={['SendNotification']='Water level is high for station '..StationName..'#Current level is '..ResultHeight[#ResultHeight][2]..'m for '..StationName..'#0#sound#extradata#telegram'} n=n+1 end end else if (debug) then print('Height level is empty.') end end if (#ResultSpeed ~= 0) then if (debug) then print("ResultSpeed: "..ResultSpeed[#ResultSpeed][2]) end update(IDXSpeed, ResultSpeed[#ResultSpeed][2]) if (NotifSpeedA) then if (tostring(ResultSpeed[#ResultSpeed][2]) > NotifSpeedV) then commandArray[n]={['SendNotification']='Water speed level is high for station '..StationName..'#Current speed level: '..ResultSpeed[#ResultSpeed][2]..'m3/s for '..StationName..'#0#sound#extradata#telegram'} n=n+1 end end else if (debug) then print('Speed is empty.') end end end end return commandArray
if (time.min == 5 or time.min == 30) then
Le script s'exécute toutes les 5 mn , pourquoi time.min == 30
Je suis repassé à la version Préçédente qui fonctionne chez moi
cdt
Bertrand
cdt
Bertrand
Code : Tout sélectionner
curl = 'C:/curl-7.50.3-win32-mingw/bin/curl.exe '