Execution d'un script variable
Publié : 01 janv. 2017, 12:17
Bonjour, je planche depuis deux jours sur pourquoi mon script variable s’exécute quand je change la variable manuellement et pas au changement d'une variable dans un script.
Je vais essayé d'être explicite.
j'ai un script device qui change la valeur de variables et celà fonctionne
ensuite j'ai un script "script_variable_controlepoele.lua"
Quand je change manuellement, j'ai ceci dans le log :
Je vais essayé d'être explicite.
j'ai un script device qui change la valeur de variables et celà fonctionne
Code : Tout sélectionner
commandArray = {}
print("Variable controle poele avant = " .. uservariables["ControlePoele"])
if (devicechanged['Puissance']) == '1' then
if (uservariables["ModePoele"]) == "1" then
commandArray['Variable:PuissancePoele'] = "1"
--commandArray['Variable:ControlePoele'] = '1'
commande ="http://192.168.0.3:8080/json.htm?type=command¶m=updateuservariable&idx=8&vname=ControlePoele&vtype=string&vvalue=1"
os.execute(commande)
print("Puissance changée à 1")
else
commandArray['UpdateDevice']='4|0|' .. uservariables["PuissancePoele"] .. '0'
print ("Puissance remis à sa valeur")
end
end
print("Variable controle poele après = " .. uservariables["ControlePoele"])
return commandArray
ensuite j'ai un script "script_variable_controlepoele.lua"
Code : Tout sélectionner
commandArray = {}
local ID = uservariables["IdPoele"]
local Mode = uservariables["ModePoele"]
local User = uservariables["BipPoele"]
local Puissance = uservariables["PuissancePoele"]
local Ventilateur1 = uservariables["VentilationPoele"]
local Ventilateur2 = "1"
print ("----------------------------Controle poele----------------------------------")
if (uservariables["ControlePoele"]) == "1" then
TrameCommande = ID .. " " .. Mode .. " " .. User .. " " .. Puissance .. " " .. Ventilateur1 .. " " .. Ventilateur2
print ("Création de la trame et envoi des de la commande")
if uservariables["VariableTrameCommande"] ~= TrameCommande then
commandArray['Variable:VariableTrameCommande'] = TrameCommande
--os.execute("/home/pi/APPLI_MCZ/src/Appli_Cmd_Arg " .. TrameCommande )
print(TrameCommande)
local start = os.clock()
while os.clock() - start < 1 do end
--os.execute("/home/pi/APPLI_MCZ/src/Appli_Cmd_Arg " .. TrameCommande )
print(TrameCommande)
local start = os.clock()
while os.clock() - start < 1 do end
--os.execute("/home/pi/APPLI_MCZ/src/Appli_Cmd_Arg " .. TrameCommande )
print(TrameCommande)
commandArray['Variable:ControlePoele'] = "0"
end
end
return commandArray
Code : Tout sélectionner
2017-01-01 12:15:21.139 LUA: ----------------------------Controle poele----------------------------------
2017-01-01 12:15:21.139 LUA: Création de la trame et envoi des de la commande
2017-01-01 12:15:21.139 LUA: 10152450 1 2 3 1 1
2017-01-01 12:15:22.139 LUA: 10152450 1 2 3 1 1
2017-01-01 12:15:23.154 LUA: 10152450 1 2 3 1 1
2017-01-01 12:15:23.156 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_variable_controlepoele.lua