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 <\>.
thier a écrit :Tu remplaces end par else. Comme ça si tes ping sont bons tu fais ton print sinon tu fais ce qui est après else
Ok merci.
Le problème est que si j'utilise un commandArray['device'] à la suite du else, a chaque echec du ping je vais ré écrire l'état du device, donc impossible d'utiliser un devicehanged par la suite.
Bref j'ai bidouillé et fini par trouver une solution qui fonctionne
Si une fonction existait pour sortir du script complètement, elle m'aurait simplifié la vie.
commandArray = {}
time = os.date("*t")
t=tonumber(otherdevices_svalues['ConsigneT'])
-- quelqu'un arrive
if (devicechanged['Cat'] =='On' or devicechanged['Cédric']=='On' ) and otherdevices['Presence']=='Off' -- Si tel ok et qu'iln'y avas personne ,retour, roomba à la base et augmentation de la temprérature de 3 °c
then
commandArray['Presence']='On'
commandArray['RoombaDock']='On'
t = t + 30
commandArray['ConsigneT']='Set Level '..t
commandArray['Variable:consigne']=otherdevices_svalues['ConsigneT'] --synchro
end
-- tout le monde est parti
if ( (((devicechanged['Cat'] =='Off' and otherdevices['Cédric']=='Off' ) and otherdevices['Presence']=='On') or
((devicechanged['Cédric'] =='Off' and otherdevices['cat']=='Off' ) and otherdevices['Presence']=='On') or
((devicechanged['Cat'] =='Off'and devicechanged['Cédric']=='Off' ) and otherdevices['Presence']=='On')) ) --
then
commandArray['Presence']='Off'
t = t - 30
commandArray['ConsigneT']='Set Level '..t
commandArray['Variable:consigne']=otherdevices_svalues['ConsigneT']
if (time.hour>8 and time.hour<19) then
commandArray['RoombaClean']='On'
commandArray['OpenURL'] = 'https://smsapi.free-mobile.fr/sendmsg?user=xxxxxxxx&pass=xxxxxxxxxxxxx&msg=RoombaClean !!'
print('Départ du Roomba.')
end
end
-- personne n'arrive,ni ne part...
if (devicechanged['Cat'] =='Off' and devicechanged['Cédric']=='Off' ) and otherdevices['Presence']=='Off'
then
print('Aucun changement')
end
return commandArray