Re: aide pour réalisation script en lua
Publié : 10 mai 2020, 22:18
pour commencer je redis la variable le type c'est pas entier c'est chaine.
Bien vu Keros
Bien vu Keros
Reprenez le contrôle de votre domotique
https://easydomoticz.com/forum/
Erreur, mal lu. Autant pour moi.thier a écrit : 10 mai 2020, 22:18 pour commencer je redis la variable le type c'est pas entier c'est chaine.
Bien vu Keros
Code : Tout sélectionner
commandArray = {}
-- loop through all the changed devices
for deviceName,deviceValue in pairs(devicechanged) do
print ("Device based event fired on '"..deviceName.."', value '"..tostring(deviceValue).."'");
-- if (deviceName=='myDevice') then
-- if deviceValue == "On" then
-- print("Device is On")
-- elseif deviceValue == "Off" then
-- commandArray['a device name'] = "On"
-- commandArray['another device name'] = "Off AFTER 10"
-- commandArray['Scene:MyScene'] = "Off"
-- commandArray['Group:My Group'] = "Off AFTER 30"
-- end
-- end
end
return commandArrayJ'ai oublié de prendre une capture mais il existe bien
Ok et du coup ca donnerait quoi ?Keros a écrit : 10 mai 2020, 22:23 Il faut revenir au source de DomoticZ : le script propre s'écrit ainsi :
Je pense que le code devicechanged['Nuit']=='On' ne fonctionne pas.Code : Tout sélectionner
for deviceName,deviceValue in pairs(devicechanged) do print ("Device based event fired on '"..deviceName.."', value '"..tostring(deviceValue).."'"); -- if (deviceName=='myDevice') then -- if deviceValue == "On" then -- print("Device is On") -- elseif deviceValue == "Off" then -- commandArray['a device name'] = "On" -- commandArray['another device name'] = "Off AFTER 10" -- commandArray['Scene:MyScene'] = "Off" -- commandArray['Group:My Group'] = "Off AFTER 30" -- end -- end end
C'est bien là le mystère. j'ai des scripts device qui démarre par if (devicechanged['XXX']=='On')et ça fonctionne.Keros a écrit : 10 mai 2020, 22:23 Il faut revenir au source de DomoticZ : le script propre s'écrit ainsi :
Je pense que le code devicechanged['Nuit']=='On' ne fonctionne pas.Code : Tout sélectionner
commandArray = {} -- loop through all the changed devices for deviceName,deviceValue in pairs(devicechanged) do print ("Device based event fired on '"..deviceName.."', value '"..tostring(deviceValue).."'"); -- if (deviceName=='myDevice') then -- if deviceValue == "On" then -- print("Device is On") -- elseif deviceValue == "Off" then -- commandArray['a device name'] = "On" -- commandArray['another device name'] = "Off AFTER 10" -- commandArray['Scene:MyScene'] = "Off" -- commandArray['Group:My Group'] = "Off AFTER 30" -- end -- end end return commandArray
Code : Tout sélectionner
commandArray = {}
-- loop through all the changed devices
for deviceName,deviceValue in pairs(devicechanged) do
print ("Device based event fired on '"..deviceName.."', value '"..tostring(deviceValue).."'");
if (deviceName=='Nuit') then
if deviceValue == "On" then
print("Nuit is On")
commandArray['Store Terrasse']='Off'
end
end
end
return commandArray