Activer planning avec un script

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 <\>.
stephG38
Messages : 72
Inscription : 04 déc. 2016, 20:35

Activer planning avec un script

Message 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&param=enabletimer&idx='.. timerID}
indexArray=indexArray+1
else
commandArray[indexArray]={['OpenURL']=ip..'/json.htm?type=command&param=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
vil1driver
Messages : 5661
Inscription : 30 janv. 2015, 11:07
Localisation : Rennes (35)

Re: Activer planning avec un script

Message 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&param=enabletimer&idx='..timerID
elseif (devicechanged[ArroAuto] == 'Off') then
	commandArray['OpenURL']=ip..'/json.htm?type=command&param=disabletimer&idx='..timerID
end
return commandArray
ps: au lieu de choisir de mettre ton code en gras 'B', choisi le bouton 'code' ;)
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
thier
Messages : 807
Inscription : 26 sept. 2015, 10:32
Localisation : charente

Re: Activer planning avec un script

Message 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
PI3+, Buster, Domoticz V2020.2, rflink, zwave, chauffage piloté par qubino, sondes oregon et Vil1d, boite aux lettres détection passage facteur, volets roulants qubino fibaro.
stephG38
Messages : 72
Inscription : 04 déc. 2016, 20:35

Re: Activer planning avec un script

Message 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 !!
stephG38
Messages : 72
Inscription : 04 déc. 2016, 20:35

Re: Activer planning avec un script

Message 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
vil1driver
Messages : 5661
Inscription : 30 janv. 2015, 11:07
Localisation : Rennes (35)

Re: Activer planning avec un script

Message par vil1driver »

Password ?
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
stephG38
Messages : 72
Inscription : 04 déc. 2016, 20:35

Re: Activer planning avec un script

Message 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
vil1driver
Messages : 5661
Inscription : 30 janv. 2015, 11:07
Localisation : Rennes (35)

Re: Activer planning avec un script

Message par vil1driver »

avant de chercher comment faire..
valide la théorie en désactivant le password dans domoticz
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
stephG38
Messages : 72
Inscription : 04 déc. 2016, 20:35

Re: Activer planning avec un script

Message par stephG38 »

Ou
Je vais essayé ce soir
Merci pour ton aide
stephG38
Messages : 72
Inscription : 04 déc. 2016, 20:35

Re: Activer planning avec un script

Message 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&param=enabletimer&idx='..9
    commandArray['OpenURL']=ip..'/json.htm?type=command&param=enabletimer&idx='..11
    commandArray['OpenURL']=ip..'/json.htm?type=command&param=enabletimer&idx='..13
   
elseif (devicechanged[ArroAuto] == 'Off') then
   commandArray['OpenURL']=ip..'/json.htm?type=command&param=disabletimer&idx='..9
   commandArray['OpenURL']=ip..'/json.htm?type=command&param=disabletimer&idx='..11
   commandArray['OpenURL']=ip..'/json.htm?type=command&param=disabletimer&idx='..13
end
return commandArray
Merci pour ton aide encore une fois !!
stéphane
Répondre