os.execute

Forum dédié aux problématiques concernant les scripts pour DomoticZ.
Entourez votre code et les logs avec les balises nommées code grâce au bouton <\>.
Arno-Strasbourg
Messages : 46
Inscription : 11 oct. 2016, 23:30

os.execute

Message par Arno-Strasbourg »

Bonjour,

JE suis sous Domoticz pour windows et j'essaye d'écrire un fichier .txt par la commande

Code : Tout sélectionner

os.execute('curl http://www.lcsqa.org/surveillance/indices/prevus/jour/xml > c:\\tmp\\pollution.txt)
Malheureusement, le fichier est bien créé mais il est vide. Pourtant lorsque je tape cette commande directement dans le dos, ça marche.

Quelqu’un voit où est le problème ?

Merci.
@rn0.

DMZ + Xibo sur Raspberry Pi pour le bureau
DMZ + Custom Page sur W7 pour la maison récemment transféré sur
DS216se Synology - DSM 6.1.1-15101 Update 1 / Domoticz 3.0.7376-7 / Mosquitto 1.4.9-5
patrice
Messages : 1720
Inscription : 22 sept. 2014, 21:51

Re: os.execute

Message par patrice »

Bonjour
Tu ne referme pas le ' après la ( dans ton exemple


Envoyé de mon PULP 4G en utilisant Tapatalk
Raspberry pi 3, Dongle RfxCom et Zigate +, plugin de pipiche, Volets Roulants profalux, contrôle d'éclairage, détecteurs de présence, alarme incendie, pilotage livebox ...
Objectif : WAF > 1
Arno-Strasbourg
Messages : 46
Inscription : 11 oct. 2016, 23:30

Re: os.execute

Message par Arno-Strasbourg »

Merci Patrice,

Ce n'est pas ça. En réalité mon code est :

Code : Tout sélectionner

local fname = 'c:\\tmp\\pollution_air.txt'
os.execute('curl http://www.lcsqa.org/surveillance/indices/prevus/jour/xml > '..fname)
J'avais simplifié (en oubliant le '). Mais le problème est ailleurs.
@rn0.

DMZ + Xibo sur Raspberry Pi pour le bureau
DMZ + Custom Page sur W7 pour la maison récemment transféré sur
DS216se Synology - DSM 6.1.1-15101 Update 1 / Domoticz 3.0.7376-7 / Mosquitto 1.4.9-5
Arno-Strasbourg
Messages : 46
Inscription : 11 oct. 2016, 23:30

Re: os.execute

Message par Arno-Strasbourg »

Allez je me réponds à moi-même. J'aurais passé mon dimanche dessus.

Je ne sais pour quelle raison, ça ça ne fonctionne pas :

Code : Tout sélectionner

local fname = 'c:\\tmp\\pollution_air.xml'
curl = 'c:\\curl\\curl.exe'
os.capture("curl http://www.lcsqa.org/surveillance/indices/prevus/jour/xml > ".. fname)
En fait, il faut écrire :

Code : Tout sélectionner

local fname = 'c:\\tmp\\pollution_air.xml'
os.capture("c:\\curl\\curl http://www.lcsqa.org/surveillance/indices/prevus/jour/xml > ".. fname)
Bonne fin de we à tous
@rn0.

DMZ + Xibo sur Raspberry Pi pour le bureau
DMZ + Custom Page sur W7 pour la maison récemment transféré sur
DS216se Synology - DSM 6.1.1-15101 Update 1 / Domoticz 3.0.7376-7 / Mosquitto 1.4.9-5
mich423
Messages : 44
Inscription : 23 avr. 2015, 21:44

Re: os.execute

Message par mich423 »

Bonsoir,
Pourrais-tu mettre ton script entier, je suis après m'arracher les cheveux en essayant de mettre en place ce même script sous windows.
Voici le mien, si je l'exécute, il réinitialise domoticz, je ne vois pas ou est l'erreur. Merci d'avance.
--[[
name : script_time_pollution.lua
auteur : papoo
version : 1.12
date : 17/05/2016
basé sur l'article http://easydomoticz.com/domoticz-integr ... -de-paris/ et le commentaire de nam
Ce script a pour but de remonter les informations de pollution du site http://www.lcsqa.org 2 fois par jour à 07H10 et 18H10 (éditable ligne 57)
sur domoticz et de nous alerter le cas écheant selon le niveau de notification choisi
L'indice de pollution remonte sur un widget Alert
]]--
-- ========================================================================
-- Variables à éditer
-- ========================================================================
local ville='ROANNE' --[[ seules les villes suivantes ont des informations sur la pollution! Certaines n'ont que l'indice de pollution disponible, d'autres
ont toutes ou parties des différents sous indices. Pensez à verifier sur le site de http://www.lcsqa.org/surveillance/indices/liste/jour les informations disponibles.
Liste des villes (98):
FORT-DE-FRANCE, AIRVAULT, AIX-EN-PROVENCE, AJACCIO, ALBERTVILLE, ALENCON, AMIENS, ANGOULEME, ANNECY, ANNEMASSE, ARMENTIERES, ARRAS, AUBAGNE, AURILLAC, AUXERRE,
AVIGNON, BASTIA, BETHUNE, BOURG-EN-BRESSE, BOURGOIN-JALLIEU, BRIGNOLES, BRIVE-LA-GAILLARDE, CAEN, CALAIS, CANNES, CHALONS-EN-CHAMPAGNE, CHAMBERY,
CHAMONIX-MONT-BLANC, CHARLEVILLE-MEZIERES, CHERBOURG-OCTEVILLE, CLERMONT-FERRAND, COGNAC, COLMAR, CREIL, DIJON, DOUAI, DUNKERQUE, EVREUX, FORBACH, GAP,
GRANDFONTAINE, GRENOBLE, GUERET, HAVRE, HYERES, ISSOIRE, LENS, LILLE, LIMOGES, LISIEUX, LYON, MACON, MARSEILLE, MAUBEUGE, METZ, MONTCEAU-LES-MINES, MONTLUCON,
MOULINS, MULHOUSE, MUNCHHAUSEN, NANCY, NEVERS, NICE, NIORT, PARIS, PASSY, PETITE-PIERRE, POITIERS, PUY-EN-VELAY, REIMS, RIOM, ROANNE, ROCHELLE, ROMANS-SUR-ISERE,
ROUEN, SAINT-DENIS, SAINT-DIZIER, SAINT-ETIENNE, SAINT-JUNIEN, SAINT-OMER, SAINT-PAUL, SAINT-PIERRE, SAINT-QUENTIN, SENS, STRASBOURG, THIONVILLE, TOULON, TROYES,
TULLE, VALENCE, VALENCIENNES, VENACO, VIENNE, VILLAGE-NEUF, BOULOGNE-SUR-MER, CHALON-SUR-SAONE, SAINT-JEAN-DE-MAURIENNE, SAINT-LO
]]--

local dz_indice_alert = nil -- renseigner l'id du device alert pollution associé si souhaité, sinon nil (dummy - alert)
local dz_indice_log = 53 -- renseigner l'id du device indice de pollution associé si souhaité, sinon nil (pour le log des données avec graphique)
local dz_o3 = 57 -- renseigner l'id du device Ozone associé si souhaité, sinon nil
local dz_no2 = nil -- renseigner l'id du device dioxyde d'azote associé si souhaité, sinon nil
local dz_PM10 = 54 -- renseigner l'id du device taux de particules associé si souhaité, sinon nil
local dz_so2 = 55 -- renseigner l'id du device dioxyde de soufre associé si souhaité, sinon nil
local dz_com = nil -- renseigner l'id du device texte commentaire associé si souhaité, sinon nil
local dz_source = nil -- renseigner l'id du device texte lien vers la source des mesures associé si souhaité, sinon nil
local send_notification = 4 -- 0: aucune notification, 1: toutes, 2: (2> Pollution <4), 3: (4> Pollution <6), 4: (6> Pollution <8), 5: (Pollution >8)
local debugging = false -- true pour voir les logs dans la console log Dz ou false pour ne pas les voir

-- ========================================================================
-- Fin Variables à éditer
-- ========================================================================
local dateIndice= nil
local CodeInsee= nil
local valeurIndice= nil
local SousIndiceO3= nil
local SousIndiceNO2= nil
local SousIndicePM10= nil
local SousIndiceSO2= nil
local Commentaire= nil
local sourceAASQA= nil
local indexArray=0
---------------------------------------------------------------------------
--Fonctions
---------------------------------------------------------------------------
function voir_les_logs (s)
if (debugging) then
print ("<font color='#f3031d'>".. s .."</font>");
end
end
---------------------------------------------------------------------------
-- Fin Fonctions
---------------------------------------------------------------------------
commandArray = {}
now=os.date("*t")
if (now.min == 43 and ((now.hour == 7) or (now.hour == 13) or (now.hour == 19))) then -- 3 éxecutions du script par jour à 7H10, 13h10 et 18H10
voir_les_logs("script_time_pollution.lua",debugging)


-- deux methodes pour récuperer les informations xml, WGET ou CURL si vous décommentez la methode curl pensez à commenter la methode wget
-- début methode wget
-- local wget = 'C:\\wget\\wget.exe '
--local fname ="C:\\pollution_air.xml"
-- os.execute("wget -q -O " .. fname .. " http://www.lcsqa.org/surveillance/indic ... s/jour/xml")

-- fin methode wget

-- début methode curl
--local fname ="/tmp/pollution_air.xml"
--os.execute("curl http://www.lcsqa.org/surveillance/indic ... s/jour/xml > ".. fname .." && chmod 777 " .. fname)
local curl = 'c:\\curl-7.50.3-win32-mingw\\bin\\curl.exe '
local fname = 'c:\\tmp\\pollution_air.xml'
os.execute(curl.."http://www.lcsqa.org/surveillance/indic ... s/jour/xml > ".. fname)
-- fin methode curl


voir_les_logs("Fichier local : " ..fname,debugging)
local f = io.open(fname, "r")

if f == nil then
print("Error opening file '" .. fname .. "'.")
os.exit(1)
end

local xml = f:read("*all")
f:close()


for instance in xml:gmatch("<node>(.-)</node>") do
agglomeration=instance:match('<agglomeration>(.-)</agglomeration>')
if agglomeration == ville then
dateIndice=instance:match('<dateIndice>(.-)</dateIndice>')
CodeInsee=instance:match('<agglomerationCodeInsee>(.-)</agglomerationCodeInsee>')
valeurIndice=instance:match('<valeurIndice>(.-)</valeurIndice>')
SousIndiceO3=instance:match('<SousIndiceO3>(.-)</SousIndiceO3>')
SousIndiceNO2=instance:match('<SousIndiceNO2>(.-)</SousIndiceNO2>')
SousIndicePM10=instance:match('<SousIndicePM10>(.-)</SousIndicePM10>')
SousIndiceSO2=instance:match('<SousIndiceSO2>(.-)</SousIndiceSO2>')
Commentaire=instance:match('<Commentaire>(.-)</Commentaire>')
sourceAASQA=instance:match('<sourceAASQA>(.-)</sourceAASQA>')
end
end



if valeurIndice == nil and dz_indice_alert ~= nil then
commandArray[indexArray] = {['UpdateDevice'] = dz_indice_alert..'|0|Aucune donn&eacute;e disponible'}
voir_les_logs("--- --- --- Aucune donn&eacute;e disponible pour la ville : ".. ville,debugging)
indexArray=indexArray+1
end


if valeurIndice ~= nil then
voir_les_logs("--- --- --- dateIndice : ".. dateIndice,debugging)
voir_les_logs("--- --- --- CodeInsee : ".. CodeInsee,debugging)
voir_les_logs("--- --- --- Agglomeration : ".. ville,debugging)
voir_les_logs("--- --- --- valeurIndice : ".. valeurIndice,debugging)
voir_les_logs("--- --- --- SousIndiceO3 : ".. SousIndiceO3,debugging)
voir_les_logs("--- --- --- SousIndiceNO2 : ".. SousIndiceNO2,debugging)
voir_les_logs("--- --- --- SousIndicePM10 : ".. SousIndicePM10,debugging)
voir_les_logs("--- --- --- SousIndiceSO2 : ".. SousIndiceSO2,debugging)
voir_les_logs("--- --- --- Commentaire : ".. Commentaire,debugging)
voir_les_logs("--- --- --- sourceAASQA : ".. sourceAASQA,debugging)



if tonumber(valeurIndice) <= 4 then -- niveau 2
if dz_indice_alert ~= nil then
commandArray[indexArray] = {['UpdateDevice'] = dz_indice_alert..'|1|Pas de Pollution'}
indexArray=indexArray+1
end
if send_notification > 0 and send_notification < 2 then
commandArray[indexArray] = {['SendNotification'] = 'Alerte Pollution#Pas de Pollution!'}
indexArray=indexArray+1
end
voir_les_logs("--- --- --- Pas de pollution --- --- ---",debugging)


elseif tonumber(valeurIndice) <= 6 then -- niveau 3
if dz_indice_alert ~= nil then
commandArray[indexArray] = {['UpdateDevice'] = dz_indice_alert..'|2|Polution Faible'}
indexArray=indexArray+1
end
if send_notification > 0 and send_notification < 3 then
commandArray[indexArray] = {['SendNotification'] = 'Alerte Pollution#Pollution Faible!'}
indexArray=indexArray+1
end
voir_les_logs("--- --- --- Pollution Faible --- --- ---",debugging)


elseif tonumber(valeurIndice) <= 8 then -- niveau 4
if dz_indice_alert ~= nil then
commandArray[indexArray] = {['UpdateDevice'] = dz_indice_alert..'|3|Pollution Forte'}
indexArray=indexArray+1
end
if send_notification > 0 and send_notification < 4 then
commandArray[indexArray] = {['SendNotification'] = 'Alerte Pollution#Pollution Forte!'}
indexArray=indexArray+1
end
voir_les_logs("--- --- --- Pollution Forte --- --- ---",debugging)


elseif tonumber(valeurIndice) > 8 then -- niveau 5
if dz_indice_alert ~= nil then
commandArray[indexArray] = {['UpdateDevice'] = dz_indice_alert..'|4|Pollution tr&eacute;s forte'}
indexArray=indexArray+1
end
if send_notification > 0 and send_notification < 5 then
commandArray[indexArray] = {['SendNotification'] = 'Alerte Pollution#Pollution tr&eacute;s forte!'}
indexArray=indexArray+1
end
voir_les_logs("--- --- --- Pollution très forte --- --- ---",debugging)

else
print("niveau non defini")
end

if dz_indice_log ~= nil then -- Mise à jour du devise O3 si il existe
commandArray[indexArray] = {['UpdateDevice'] = dz_indice_log..'|0|'.. tostring(valeurIndice)}
indexArray=indexArray+1
end
if dz_no2 ~= nil then -- Mise à jour du devise NO3 si il existe
commandArray[indexArray] = {['UpdateDevice'] = dz_no2..'|0|'.. tostring(SousIndiceNO2)}
indexArray=indexArray+1
end
if dz_PM10 ~= nil then -- Mise à jour du devise PM10 si il existe
commandArray[indexArray] = {['UpdateDevice'] = dz_PM10..'|0|'.. tostring(SousIndicePM10)}
indexArray=indexArray+1
end
if dz_so2 ~= nil then -- Mise à jour du devise SO2 si il existe
commandArray[indexArray] = {['UpdateDevice'] = dz_so2..'|0|'.. tostring(SousIndiceSO2)}
indexArray=indexArray+1
end
if dz_com ~= nil then -- Mise à jour du devise Commentaire si il existe
commandArray[indexArray] = {['UpdateDevice'] = dz_com..'|0|'.. tostring(Commentaire)}
indexArray=indexArray+1
end
if dz_source ~= nil then -- Mise à jour du devise Source si il existe
sourceAASQAhtml = '<a href="'.. sourceAASQA ..'">'.. sourceAASQA ..'</a>'
commandArray[indexArray] = {['UpdateDevice'] = dz_source..'|0|'.. tostring(sourceAASQAhtml)}
indexArray=indexArray+1
end
end

end
return commandArray
Domoticz sur Win7 - 4 ds18s20 1-Wire avec ESP8266 - 4 modules relais avec ESP8266- conso EDF OWL CM 180 - RFXTrx433 - Rflink - 4 capteurs température 433Mhz Oregon DIY - 3 Rising Sun - 4 Chacon - Yana Server - Imperihome - Cde portail avec ZK1PA -
Arno-Strasbourg
Messages : 46
Inscription : 11 oct. 2016, 23:30

Re: os.execute

Message par Arno-Strasbourg »

Je suis finalement passé sur Raspberry. Beaucoup plus simple que windows !!

Mais voici mon code :

Code : Tout sélectionner

--[[
name : script_time_pollution.lua
auteur : papoo
version : 1.12
date : 17/05/2016
basé sur l'article http://easydomoticz.com/domoticz-integrer-les-donnees-qualite-de-lair-en-dehors-de-paris/ et le commentaire de nam
 Ce script a pour but de remonter les informations de pollution du site http://www.lcsqa.org 2 fois par jour à 07H10 et 18H10 (éditable ligne 57)
 sur domoticz et de nous alerter le cas écheant selon le niveau de notification choisi
 L'indice de pollution remonte sur un widget Alert
]]--
-- ========================================================================
-- Variables à éditer
-- ========================================================================
local ville='STRASBOURG'  --[[  seules les villes suivantes ont des informations sur la pollution! Certaines n'ont que l'indice de pollution disponible, d'autres 
ont toutes ou parties des différents sous indices. Pensez à verifier sur le site de http://www.lcsqa.org/surveillance/indices/liste/jour les informations disponibles.
Liste des villes (98): 
FORT-DE-FRANCE, AIRVAULT, AIX-EN-PROVENCE, AJACCIO, ALBERTVILLE, ALENCON, AMIENS, ANGOULEME, ANNECY, ANNEMASSE, ARMENTIERES, ARRAS, AUBAGNE, AURILLAC, AUXERRE,
AVIGNON, BASTIA, BETHUNE, BOURG-EN-BRESSE, BOURGOIN-JALLIEU, BRIGNOLES, BRIVE-LA-GAILLARDE, CAEN, CALAIS, CANNES, CHALONS-EN-CHAMPAGNE, CHAMBERY, 
CHAMONIX-MONT-BLANC, CHARLEVILLE-MEZIERES, CHERBOURG-OCTEVILLE, CLERMONT-FERRAND, COGNAC, COLMAR, CREIL, DIJON, DOUAI, DUNKERQUE, EVREUX, FORBACH, GAP, 
GRANDFONTAINE, GRENOBLE, GUERET, HAVRE, HYERES, ISSOIRE, LENS, LILLE, LIMOGES, LISIEUX, LYON, MACON, MARSEILLE, MAUBEUGE, METZ, MONTCEAU-LES-MINES, MONTLUCON, 
MOULINS, MULHOUSE, MUNCHHAUSEN, NANCY, NEVERS, NICE, NIORT, PARIS, PASSY, PETITE-PIERRE, POITIERS, PUY-EN-VELAY, REIMS, RIOM, ROANNE, ROCHELLE, ROMANS-SUR-ISERE, 
ROUEN, SAINT-DENIS, SAINT-DIZIER, SAINT-ETIENNE, SAINT-JUNIEN, SAINT-OMER, SAINT-PAUL, SAINT-PIERRE, SAINT-QUENTIN, SENS, STRASBOURG, THIONVILLE, TOULON, TROYES, 
TULLE, VALENCE, VALENCIENNES, VENACO, VIENNE, VILLAGE-NEUF, BOULOGNE-SUR-MER, CHALON-SUR-SAONE, SAINT-JEAN-DE-MAURIENNE, SAINT-LO
]]--

local dz_indice_alert = 50	-- renseigner l'id du device alert pollution associé si souhaité, sinon nil (dummy - alert)
local dz_indice_log = 51	-- renseigner l'id du device indice de pollution associé si souhaité, sinon nil (pour le log des données avec graphique)
local dz_o3 = nil         	-- renseigner l'id du device Ozone associé si souhaité, sinon nil
local dz_no2 = nil         	-- renseigner l'id du device dioxyde d'azote associé si souhaité, sinon nil
local dz_PM10 = nil         -- renseigner l'id du device taux de particules associé si souhaité, sinon nil
local dz_so2 = nil         	-- renseigner l'id du device dioxyde de soufre associé si souhaité, sinon nil
local dz_com = nil        	-- renseigner l'id du device texte commentaire associé si souhaité, sinon nil
local dz_source = nil       -- renseigner l'id du device texte lien vers la source des mesures associé si souhaité, sinon nil
local send_notification = 3 -- 0: aucune notification, 1: toutes, 2: (2> Pollution <4), 3: (4> Pollution <6), 4: (6> Pollution <8), 5: (Pollution >8)
local debug = true     	-- true pour voir les logs dans la console log Dz ou false pour ne pas les voir

-- ========================================================================
-- Fin Variables à éditer
-- ========================================================================
local dateIndice= nil
local CodeInsee= nil
local valeurIndice= nil
local SousIndiceO3= nil 
local SousIndiceNO2= nil
local SousIndicePM10= nil
local SousIndiceSO2= nil
local Commentaire= nil
local sourceAASQA= nil
local indexArray=0   

--------------------------------------------------------------------------- 
--Fonctions
---------------------------------------------------------------------------
function voir_les_logs (s)
    if (debug) then 
        print ("<font color='darkorange'>".. s .."</font>");
    end
end   

function os.capture(cmd)
  local f = assert(io.popen(cmd, 'r'))
  local s = assert(f:read('*a'))
  f:close()
  return s
end

--------------------------------------------------------------------------- 
-- Fin Fonctions
---------------------------------------------------------------------------

commandArray = {}
voir_les_logs('************************************')
now=os.date("*t")
-- if (now.min == 10 and ((now.hour == 7) or (now.hour == 13) or (now.hour == 18))) then -- 3 éxecutions du script par jour à 7H10, 13h10 et 18H10
if now.min % 15 == 0 then  -- execution toutes les 15 minutes

voir_les_logs("script_time_pollution.lua",debug)

		local fname = 'c:\\tmp\\pollution_air.xml'
		os.capture("c:\\curl\\curl http://www.lcsqa.org/surveillance/indices/prevus/jour/xml > ".. fname)
		  
       voir_les_logs("Fichier local : " ..fname,debug)
 
          if fname == nil then
          print("Error opening file '" .. fname .. "'.")
          end
		  
		  local r = io.open(fname, "r")
		  local xml = r:read("*all")
          r:close()
		  
	for instance in xml:gmatch("<node>(.-)</node>") do 
		agglomeration=instance:match('<agglomeration>(.-)</agglomeration>')
        if agglomeration == ville then
			dateIndice=instance:match('<dateIndice>(.-)</dateIndice>')
			CodeInsee=instance:match('<agglomerationCodeInsee>(.-)</agglomerationCodeInsee>')
			valeurIndice=instance:match('<valeurIndice>(.-)</valeurIndice>')
			SousIndiceO3=instance:match('<SousIndiceO3>(.-)</SousIndiceO3>')
			SousIndiceNO2=instance:match('<SousIndiceNO2>(.-)</SousIndiceNO2>')
			SousIndicePM10=instance:match('<SousIndicePM10>(.-)</SousIndicePM10>')
			SousIndiceSO2=instance:match('<SousIndiceSO2>(.-)</SousIndiceSO2>')
			Commentaire=instance:match('<Commentaire>(.-)</Commentaire>')
			sourceAASQA=instance:match('<sourceAASQA>(.-)</sourceAASQA>')
        end
	end

       
       
      if valeurIndice == nil and dz_indice_alert ~= nil then
         commandArray[indexArray] = {['UpdateDevice'] = dz_indice_alert..'|0|Aucune donn&eacute;e disponible'}
         voir_les_logs("--- --- --- Aucune donn&eacute;e disponible pour la ville : ".. ville,debug) 
         indexArray=indexArray+1
      end   


   if valeurIndice   ~= nil then   
      voir_les_logs("--- --- --- dateIndice : ".. dateIndice,debug)
      voir_les_logs("--- --- --- CodeInsee : ".. CodeInsee,debug)
      voir_les_logs("--- --- --- Agglomeration : ".. ville,debug)
      voir_les_logs("--- --- --- valeurIndice : ".. valeurIndice..'/10',debug)
      voir_les_logs("--- --- --- SousIndiceO3 : ".. SousIndiceO3,debug)
      voir_les_logs("--- --- --- SousIndiceNO2 : ".. SousIndiceNO2,debug)
      voir_les_logs("--- --- --- SousIndicePM10 : ".. SousIndicePM10,debug)
      voir_les_logs("--- --- --- SousIndiceSO2 : ".. SousIndiceSO2,debug)
      voir_les_logs("--- --- --- Commentaire : ".. Commentaire,debug)
      voir_les_logs("--- --- --- sourceAASQA : ".. sourceAASQA,debug)

       

      if tonumber(valeurIndice) <= 4   then -- niveau 2
        if dz_indice_alert ~= nil then
          commandArray[indexArray] = {['UpdateDevice'] = dz_indice_alert..'|1|Pas de Pollution'}
          indexArray=indexArray+1
        end
        if send_notification > 0 and send_notification < 2 then
          commandArray[indexArray] = {['SendNotification'] = 'Alerte Pollution#Pas de Pollution!'}
          indexArray=indexArray+1
        end
        voir_les_logs("--- --- --- Pas de pollution --- --- ---",debug)

        
      elseif tonumber(valeurIndice) <= 6   then -- niveau 3
        if dz_indice_alert ~= nil then
          commandArray[indexArray] = {['UpdateDevice'] = dz_indice_alert..'|2|Polution Faible'}
          indexArray=indexArray+1
        end
        if send_notification > 0 and send_notification < 3 then
          commandArray[indexArray] = {['SendNotification'] = 'Alerte Pollution#Pollution Faible!'}
          indexArray=indexArray+1
        end
        voir_les_logs("--- --- --- Pollution Faible --- --- ---",debug)   


      elseif tonumber(valeurIndice) <= 8   then -- niveau 4
        if dz_indice_alert ~= nil then
          commandArray[indexArray] = {['UpdateDevice'] = dz_indice_alert..'|3|Pollution Forte'}
          indexArray=indexArray+1
        end
        if send_notification > 0 and send_notification < 4 then
          commandArray[indexArray] = {['SendNotification'] = 'Alerte Pollution#Pollution Forte!'}
          indexArray=indexArray+1
        end
        voir_les_logs("--- --- --- Pollution Forte --- --- ---",debug)      


      elseif tonumber(valeurIndice) > 8  then -- niveau 5
        if dz_indice_alert ~= nil then
          commandArray[indexArray] = {['UpdateDevice'] = dz_indice_alert..'|4|Pollution tr&eacute;s forte'}
          indexArray=indexArray+1
        end
        if send_notification > 0 and send_notification < 5 then
          commandArray[indexArray] = {['SendNotification'] = 'Alerte Pollution#Pollution tr&eacute;s forte!'}
          indexArray=indexArray+1
        end
        voir_les_logs("--- --- --- Pollution très forte --- --- ---",debug)

      else
        print("niveau non defini")
      end      
         
        if dz_indice_log ~= nil then -- Mise à jour du device O3 si il existe
          commandArray[indexArray] = {['UpdateDevice'] = dz_indice_log..'|0|'.. tostring(valeurIndice)..'/10'}
          indexArray=indexArray+1
        end   
        if dz_no2 ~= nil then -- Mise à jour du device NO3 si il existe
          commandArray[indexArray] = {['UpdateDevice'] = dz_no2..'|0|'.. tostring(SousIndiceNO2)}
          indexArray=indexArray+1
        end   
        if dz_PM10 ~= nil then -- Mise à jour du device PM10 si il existe
          commandArray[indexArray] = {['UpdateDevice'] = dz_PM10..'|0|'.. tostring(SousIndicePM10)}
          indexArray=indexArray+1
        end
        if dz_so2 ~= nil then -- Mise à jour du device SO2 si il existe
          commandArray[indexArray] = {['UpdateDevice'] = dz_so2..'|0|'.. tostring(SousIndiceSO2)}
          indexArray=indexArray+1
        end
        if dz_com ~= nil then -- Mise à jour du device Commentaire si il existe
          commandArray[indexArray] = {['UpdateDevice'] = dz_com..'|0|'.. tostring(Commentaire)}
          indexArray=indexArray+1
        end
        if dz_source ~= nil then -- Mise à jour du device Source si il existe
         sourceAASQAhtml = '<a href="'.. sourceAASQA ..'">'.. sourceAASQA ..'</a>'
          commandArray[indexArray] = {['UpdateDevice'] = dz_source..'|0|'.. tostring(sourceAASQAhtml)}
          indexArray=indexArray+1
        end     
   end      
voir_les_logs('*********************************')
end
return commandArray
Il faut évidemment mettre le fichier curl.exe dans c:\curl

Bon courage.
@rn0.

DMZ + Xibo sur Raspberry Pi pour le bureau
DMZ + Custom Page sur W7 pour la maison récemment transféré sur
DS216se Synology - DSM 6.1.1-15101 Update 1 / Domoticz 3.0.7376-7 / Mosquitto 1.4.9-5
mich423
Messages : 44
Inscription : 23 avr. 2015, 21:44

Re: os.execute

Message par mich423 »

Bonjour et merci, ça marche nickel, j'ai trouvé mon problème, mon chemin vers curl qui était trop long.
Domoticz sur Win7 - 4 ds18s20 1-Wire avec ESP8266 - 4 modules relais avec ESP8266- conso EDF OWL CM 180 - RFXTrx433 - Rflink - 4 capteurs température 433Mhz Oregon DIY - 3 Rising Sun - 4 Chacon - Yana Server - Imperihome - Cde portail avec ZK1PA -
Répondre