Page 1 sur 2
Activer planning avec un script
Publié : 16 mai 2017, 08:16
par stephG38
Bonjour à tous,
je coince sur le script suivant afin de désactiver ou activer les plannings de mon arrosage :
--------------------------------
------ Variables ------
--------------------------------
local ArroAuto = 'Arrosage Automatique' --Nom inter mise en marche arrosage auto
local ip = '192.168.2.32:8080'
local timerID ='9' -- id du timer Arrosage1
--------------------------------
-- Fin Variables --
--------------------------------
commandArray = {}
if (devicechanged[ArroAuto]) then
if (otherdevices[ArroAuto]=='On') then
commandArray[indexArray]={['OpenURL']=ip..'/json.htm?type=command¶m=enabletimer&idx='.. timerID}
indexArray=indexArray+1
else
commandArray[indexArray]={['OpenURL']=ip..'/json.htm?type=command¶m=disabletimer&idx='.. timerID}
indexArray=indexArray+1
end
end
return commandArray
Dans les log j'ai une erreur :
Error: EventSystem: in Arro3: [string "-------------------------------- ..."]:16: table index is nil
Pourtant cela fonctionne en tapant directement la commande dans le navigateur :
http://192.168.2.32:8080/json.htm?type= ... imer&idx=9
Merci par avance de votre aide !!
Stéphane
Re: Activer planning avec un script
Publié : 16 mai 2017, 08:57
par vil1driver
Salut,
ceci devrait mieux aller
Code : Tout sélectionner
--------------------------------
------ Variables ------
--------------------------------
local ArroAuto = 'Arrosage Automatique' --Nom inter mise en marche arrosage auto
local ip = '192.168.2.32:8080'
local timerID ='9' -- id du timer Arrosage1
--------------------------------
-- Fin Variables --
--------------------------------
commandArray = {}
if (devicechanged[ArroAuto] == 'On') then
commandArray['OpenURL']=ip..'/json.htm?type=command¶m=enabletimer&idx='..timerID
elseif (devicechanged[ArroAuto] == 'Off') then
commandArray['OpenURL']=ip..'/json.htm?type=command¶m=disabletimer&idx='..timerID
end
return commandArray
ps: au lieu de choisir de mettre ton code en gras 'B', choisi le bouton 'code'

Re: Activer planning avec un script
Publié : 16 mai 2017, 13:38
par thier
tu peux aussi abandonner les commandArray =indexArray+1 en remplaçant commandArray[indexArray] par commandArray[#commandArray +1]
Envoyé de mon SM-J710F en utilisant Tapatalk
Re: Activer planning avec un script
Publié : 16 mai 2017, 18:47
par stephG38
Bonjour à vous deux,
merci pour le coup de main !!
Par contre j'ai copié le script et plus d'erreur mais pas de changement sur le planning !
Dans les logs j'ai :
Code : Tout sélectionner
2017-05-16 18:41:27.704 User: SG initiated a switch command (19/Arrosage Automatique/Off)
2017-05-16 18:41:27.721 EventSystem: Fetching url...
2017-05-16 18:41:27.722 EventSystem: Script event triggered: Arro3
et
Code : Tout sélectionner
2017-05-16 18:44:16.735 User: SG initiated a switch command (19/Arrosage Automatique/On)
2017-05-16 18:44:16.752 EventSystem: Fetching url...
2017-05-16 18:44:16.752 EventSystem: Script event triggered: Arro3
J'ai bien vérifié et le planning se désactive si la commande est lancée du navigateur !!
Une idée ?
Merci par avance !
PS : Désolé pour le code mais je ne savais pas comment faire !!
Re: Activer planning avec un script
Publié : 19 mai 2017, 06:24
par stephG38
hello,
je suis toujours bloqué sur mon problème d'activation de planning !
plus d'erreur dans les logs mais pas d'effet du nouveau script !!
si quelqu'un à une idée je suis preneur !
Merci par avance !
Stéphane
Re: Activer planning avec un script
Publié : 19 mai 2017, 08:20
par vil1driver
Password ?
Re: Activer planning avec un script
Publié : 19 mai 2017, 11:51
par stephG38
Hello,
Effectivement j'ai pensé a ce problème de password mais je ne sais pas comment le gérer dans mon script !
Si tu peux m'éclairer !
Merci par avance
Stéphane
Re: Activer planning avec un script
Publié : 19 mai 2017, 12:05
par vil1driver
avant de chercher comment faire..
valide la théorie en désactivant le password dans domoticz
Re: Activer planning avec un script
Publié : 19 mai 2017, 12:11
par stephG38
Ou
Je vais essayé ce soir
Merci pour ton aide
Re: Activer planning avec un script
Publié : 19 mai 2017, 18:38
par stephG38
Super !!
Effectivement ça marche en enlevant le mot de passe de domoticz !
Comment indiquer donc dans le script le mot de passe ?
+
En testant j'ai ajouté 2 autres inter a modifier mais il ne change qu'un seul des trois quand je test !!
individuellement les 3 fonctionnes mais des que j'en met 2 il ne change qu'un seul inter !
voici le script :
Code : Tout sélectionner
--------------------------------
------ Variables ------
--------------------------------
local ArroAuto = 'Arrosage Automatique' --Nom inter mise en marche arrosage auto
local ip = '192.168.2.32:8080'
--------------------------------
-- Fin Variables --
--------------------------------
commandArray = {}
if (devicechanged[ArroAuto] == 'On') then
commandArray['OpenURL']=ip..'/json.htm?type=command¶m=enabletimer&idx='..9
commandArray['OpenURL']=ip..'/json.htm?type=command¶m=enabletimer&idx='..11
commandArray['OpenURL']=ip..'/json.htm?type=command¶m=enabletimer&idx='..13
elseif (devicechanged[ArroAuto] == 'Off') then
commandArray['OpenURL']=ip..'/json.htm?type=command¶m=disabletimer&idx='..9
commandArray['OpenURL']=ip..'/json.htm?type=command¶m=disabletimer&idx='..11
commandArray['OpenURL']=ip..'/json.htm?type=command¶m=disabletimer&idx='..13
end
return commandArray
Merci pour ton aide encore une fois !!
stéphane