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 <\>.
Bonsoir,
Les script en LUA commençant à me plaire, je compte y passer pour remplacer mes "Blockly".
Étant loin d’être un expert, ce post afin de poster mes scripts et si possible me les faire confirmer et me faire aider par les plus aguerri
Surement très simple pour vous mais .......
--SI l'Alarme passe à ON ALORS
if devicechanged['Alarme']=='ON' then
--ETEINDRE LES LUMIERES
commandArray[#commandArray+1]={['Façade arrière']='Off'}
end
commandArray[#commandArray+1]={['Appoint salon']='Off'}
end
commandArray[#commandArray+1]={['Façade avant']='Off'}
end
--SI ECLAIRAGE PISCINE état ON ALORS
if otherdevices['A1-Eclairage piscine']=='On' then
--PASSER A OFF
commandArray[#commandArray+1]={['A1-Eclairage piscine']='Off'}
end
......... encore un peu confus pour moi.
Merci.
Bonne soirée.
A+
Fab
--SI l'Alarme passe à ON ALORS
if devicechanged['Alarme']=='ON' then
--ETEINDRE LES LUMIERES
commandArray[#commandArray+1]={['Façade arrière']='Off'}
commandArray[#commandArray+1]={['Appoint salon']='Off'}
commandArray[#commandArray+1]={['Façade avant']='Off'}
--SI ECLAIRAGE PISCINE état ON ALORS
if otherdevices['A1-Eclairage piscine']=='On' then
--PASSER A OFF
commandArray[#commandArray+1]={['A1-Eclairage piscine']='Off'}
end
return commandArray
Message d'erreur :
2019-02-03 21:18:14.436 Error: EventSystem: in Script #2: [string "--SI l'Alarme passe à ON ALORS..."]:16: 'end' expected (to close 'if' at line 2) near <eof>
commandArray={}
--SI l'Alarme passe à ON ALORS
if devicechanged['Alarme']=='ON' then
--ETEINDRE LES LUMIERES
commandArray[#commandArray+1]={['Façade arrière']='Off'}
commandArray[#commandArray+1]={['Appoint salon']='Off'}
commandArray[#commandArray+1]={['Façade avant']='Off'}
end
--SI ECLAIRAGE PISCINE état ON ALORS
do if otherdevices['Alarme']=='ON' and otherdevices['A1-Eclairage piscine']=='On' then
--PASSER A OFF
commandArray[#commandArray+1]={['A1-Eclairage piscine']='Off'}
end
end
return commandArray
Plus d'erreur !
Ce que je cherche à faire :
Quand alarme ON
Façade avant, arrière et appoint salon OFF
Si Eclairage piscine ON, passage à OFF
Du coup je ne sais pas si le deuxième IF est bon ?
commandArray={}
--SI etat l'Alarme change
if devicechanged ['Alarme'] then
--SI l'Alarme passe à ON ALORS
if devicechanged['Alarme']=='ON' then
--ETEINDRE LES LUMIERES
commandArray[#commandArray + 1]={['Façade arrière']='Off'}
commandArray[#commandArray + 1]={['Appoint salon']='Off'}
commandArray[#commandArray + 1]={['Façade avant']='Off'}
end
-- SI l'Alarme passe à ON et SI ECLAIRAGE PISCINE état ON ALORS
if otherdevices['A1-Eclairage piscine']=='On' then
--PASSER A OFF
commandArray[#commandArray + 1]={['A1-Eclairage piscine']='Off'}
end
print ("Alarme activée --> extinction des éclairages allumés.")
end
return commandArray
Tout fonctionnent mais le retour à l'état OFF des interrupteurs ne se fait pas.
Grrrrrrr ..... ça va venir
commandArray={}
--SI etat l'Alarme change
if devicechanged ['Alarme'] then
--SI l'Alarme passe à ON ALORS
--if devicechanged['Alarme']=='ON' then
if otherdevices['Alarme']=='ON' then
--ETEINDRE LES LUMIERES
commandArray[#commandArray + 1]={['Façade arrière']='Off'}
commandArray[#commandArray + 1]={['Appoint salon']='Off'}
commandArray[#commandArray + 1]={['Façade avant']='Off'}
end
-- SI l'Alarme passe à ON et SI ECLAIRAGE PISCINE état ON ALORS
if otherdevices['A1-Eclairage piscine']=='On' then
--PASSER A OFF
commandArray[#commandArray + 1]={['A1-Eclairage piscine']='Off'}
end
print ("Alarme activée --> extinction des éclairages allumés.")
end
return commandArray
Bonsoir,
Merci Denis
Le fonctionnement est le même, tout s'éteint, seul l'éclairage piscine passe à l'état OFF, les trois premiers restent à ON.
Peut être rajouter à ces trois là "Si ON" passage à "OFF"