Optimisation de script
Publié : 29 août 2020, 16:53
Salut tout le monde.
J'au un script par interrupteur qui se présente comme suit (ce sont des inter xiaaomi à 4 touches possibles) :
Je pense que les latences que j'ai peuvent provenir de scripts assez mal fait comme celui là, et peut être qu'une autre façon de les écrire réduirait les latences non ?
Merci.
J'au un script par interrupteur qui se présente comme suit (ce sont des inter xiaaomi à 4 touches possibles) :
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 commandArrayMerci.