Pour mes luminaires, j'ai pour chaque interrupteur (des xiaomi controlés par zigate) des script lua comme celà :
Code : Tout sélectionner
commandArray = {}
if (devicechanged['Interrupteur Anna'] == '1 Click' and otherdevices['Virtuel Anna'] == 'Off') then
commandArray['Virtuel Anna']='On'
commandArray['Group:Lumiere blanche Anna1']='On'
commandArray['Interrupteur Anna']='Set Level: 40'
else
if (devicechanged['Interrupteur Anna'] == '1 Click' and otherdevices['Virtuel Anna'] == 'On') then
commandArray['Group:Lumiere blanche Anna1']='Off'
commandArray['Group:Lumiere blanche Anna2']='Off'
commandArray['Group:Lumiere blanche Anna rgb']='Off'
commandArray['Group:Lumiere violette Anna']='Off'
commandArray['Virtuel Anna']='Off'
commandArray['Interrupteur Anna']='Set Level: 40'
end
end
if (devicechanged['Interrupteur Anna'] == '2 Click' and otherdevices['Virtuel Anna'] == 'Off') then
commandArray['Virtuel Anna']='On'
commandArray['Group:Lumiere blanche Anna2']='On'
commandArray['Interrupteur Anna']='Set Level: 40'
else
if (devicechanged['Interrupteur Anna'] == '2 Click' and otherdevices['Virtuel Anna'] == 'On') then
commandArray['Group:Lumiere blanche Anna1']='On'
commandArray['Interrupteur Anna']='Set Level: 40'
end
end
if ((devicechanged['Interrupteur Anna'] == '3 Click' and otherdevices['Virtuel Anna'] == 'Off')) then
commandArray['Virtuel Anna']='On'
commandArray['Group:Lumiere violette Anna']='On'
commandArray['Interrupteur Anna']='Set Level: 40'
else
if ((devicechanged['Interrupteur Anna'] == '3 Click' and otherdevices['Virtuel Anna'] == 'On')) then
commandArray['Group:Lumiere blanche Anna rgb']='On'
commandArray['Interrupteur Anna']='Set Level: 40'
end
end
if ((devicechanged['Interrupteur Anna'] == '4 Click' and otherdevices['Virtuel prise Anna'] == 'Off')) then
commandArray['Virtuel prise Anna']='On'
commandArray['Prise lampe Anna']='On'
commandArray['Interrupteur Anna']='Set Level: 40'
else
if ((devicechanged['Interrupteur Anna'] == '4 Click' and otherdevices['Virtuel prise Anna'] == 'On')) then
commandArray['Virtuel prise Anna']='Off'
commandArray['Prise lampe Anna']='Off'
commandArray['Interrupteur Anna']='Set Level: 40'
end
end
return commandArray1 : Quelqu'un qui serait motivé pour ré écrire ce script en lua pour l'optimiser (enfin si possible, peut etre est il parfait mais vu mes connaissances j'en doute fort !)
2 : Quelqu'un de motivé pour me traduire ce scipt en dzvent, j'aimerai m'y mettre, mais je pige pas grand chose, donc avec un comparatif lua/dzvent, ca m'aiderait je pense.
Merci.