variable qui ne change pas lua

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 <\>.
domoticzmax
Messages : 13
Inscription : 16 mai 2020, 12:24

Re: variable qui ne change pas lua

Message par domoticzmax »

oui j'ai vu désoler et le bouton de sélection sur le choix je pensais que c’était mieux qu'il passe a off pour éviter que domoticz tour en rond dans le code car sur off il n'y a rien
vil1driver
Messages : 5661
Inscription : 30 janv. 2015, 11:07
Localisation : Rennes (35)

Re: variable qui ne change pas lua

Message par vil1driver »

il ne tournera pas en rond si le selecteur n'est pas manipulé

ps : je viens de mettre à jour le code, fais le reste sur le même principe et ça devrait rouler
MAJ = VIDER LE CACHE(<-Clicable)
/!\Les mises à jour de Domoticz sont souvent sources de difficultés, ne sautez pas dessus
modules.lua

Un ex domoticzien
domoticzmax
Messages : 13
Inscription : 16 mai 2020, 12:24

Re: variable qui ne change pas lua

Message par domoticzmax »

a d'accord car sinon il y a l'extinction après x seconde que propose domoticz qui me facilite la tache car le reste fonctionne il ne manquais plus que ça :)
j'ai mis a 2 seconde et il passe sur off
Capture3.PNG
Capture3.PNG (12.17 Kio) Consulté 1500 fois
pour ce qui veulent le code fonctionnelle le voici après des personnes peuvent faire plus simple mais ça fonctionne donc ça me va :)

Code : Tout sélectionner

commandArray = {}
local compteur = uservariables["compteur"]
print (compteur) 


if (devicechanged['rideau gauche'] == '0') then  
    if (compteur == 0 ) then
        commandArray ['rideau gauche'] = 'Off'
    elseif ( compteur == 25 ) then
        commandArray[1]={['rideau gauche up']='On'}
        commandArray[2]={['rideau gauche up']='Off AFTER 5'} 
        commandArray['Variable:compteur'] = '0'
    elseif (compteur == 50) then
        commandArray[1]={['rideau gauche up']='On'}
        commandArray[2]={['rideau gauche up']='Off AFTER 5'}  
        commandArray['Variable:compteur'] = '0'
    elseif (compteur == 75) then
        commandArray[1]={['rideau gauche up']='On'}
        commandArray[2]={['rideau gauche up']='Off AFTER 5'} 
        commandArray['Variable:compteur'] = '0'
    elseif (compteur == 100) then
        commandArray[1]={['rideau gauche up']='On'}
        commandArray[2]={['rideau gauche up']='Off AFTER 5'}   
        commandArray['Variable:compteur'] = '0'
    end
    
elseif (devicechanged['rideau gauche'] == '25') then
    if ( compteur == 0 ) then
        commandArray[1]={['rideau gauche down']='On'}
        commandArray[2]={['rideau gauche down']='Off AFTER 5'}
        commandArray['Variable:compteur'] = '25'
    elseif ( compteur == 25 ) then
        commandArray ['rideau gauche'] = 'Off'
    elseif (compteur == 50) then
        commandArray[1]={['rideau gauche up']='On'}
        commandArray[2]={['rideau gauche up']='Off AFTER 5'} 
        commandArray['Variable:compteur'] = '25'
    elseif (compteur == 75) then
        commandArray[1]={['rideau gauche up']='On'}
        commandArray[2]={['rideau gauche up']='Off AFTER 5'} 
        commandArray['Variable:compteur'] = '25'
    elseif (compteur == 100) then
        commandArray[1]={['rideau gauche up']='On'}
        commandArray[2]={['rideau gauche up']='Off AFTER 5'}  
        commandArray['Variable:compteur'] = '25'
    end   
 
elseif (devicechanged['rideau gauche'] == '50') then
    if (compteur == 0) then
        commandArray[1]={['rideau gauche down']='On'}
        commandArray[2]={['rideau gauche down']='Off AFTER 50'}
 commandArray['Variable:compteur'] = '50'
    elseif (compteur == 25) then
        commandArray[1]={['rideau gauche down']='On'}
        commandArray[2]={['rideau gauche down']='Off AFTER 25'} 
 commandArray['Variable:compteur'] = '50'
    elseif (compteur == 50) then
        commandArray ['rideau gauche'] = 'Off'
    elseif (compteur == 75) then
        commandArray[1]={['rideau gauche up']='On'}
        commandArray[2]={['rideau gauche up']='Off AFTER 25'} 
 commandArray['Variable:compteur'] = '50'   
    elseif (compteur == 100) then
        commandArray[1]={['rideau gauche up']='On'}
        commandArray[2]={['rideau gauche up']='Off AFTER 50'}  
 commandArray['Variable:compteur'] = '50'   
    end   

elseif (devicechanged['rideau gauche'] == '75') then
    if (compteur == 0) then
        commandArray[1]={['rideau gauche down']='On'}
        commandArray[2]={['rideau gauche down']='Off AFTER 75'}
 commandArray['Variable:compteur'] = '75'
    elseif (compteur == 25) then
        commandArray[1]={['rideau gauche down']='On'}
        commandArray[2]={['rideau gauche down']='Off AFTER 50'}
 commandArray['Variable:compteur'] = '75'
    elseif (compteur == 50) then
        commandArray[1]={['rideau gauche down']='On'}
        commandArray[2]={['rideau gauche down']='Off AFTER 25'} 
 commandArray['Variable:compteur'] = '75'
    elseif (compteur == 75) then
        commandArray ['rideau gauche'] = 'Off'
    elseif (compteur == 100) then
        commandArray[1]={['rideau gauche up']='On'}
        commandArray[2]={['rideau gauche up']='Off AFTER 25'}  
 commandArray['Variable:compteur'] = '75'  
    end  

elseif (devicechanged['rideau gauche'] == '100') then
    if (compteur == 0) then
        commandArray[1]={['rideau gauche down']='On'}
        commandArray[2]={['rideau gauche down']='Off AFTER 100'}
 commandArray['Variable:compteur'] = '100'
    elseif (compteur == 25) then
        commandArray[1]={['rideau gauche down']='On'}
        commandArray[2]={['rideau gauche down']='Off AFTER 75'}  
 commandArray['Variable:compteur'] = '100' 
    elseif (compteur == 50) then
        commandArray[1]={['rideau gauche down']='On'}
        commandArray[2]={['rideau gauche down']='Off AFTER 50'} 
 commandArray['Variable:compteur'] = '100' 
    elseif (compteur == 75) then
        commandArray[1]={['rideau gauche down']='On'}
        commandArray[2]={['rideau gauche down']='Off AFTER 25'} 
 commandArray['Variable:compteur'] = '100'
    elseif (compteur == 100) then
        commandArray ['rideau gauche'] = 'Off'
    end   
end
    
return commandArray
en tout cas merci beaucoup pour votre aide a tous c'est super sympa :)
Répondre