
jjacques68
Membres confirmés-
Compteur de contenus
4 349 -
Inscription
-
Dernière visite
-
Jours gagnés
39
Tout ce qui a été posté par jjacques68
-
du coup j'ai l'impression que l'on ne pas écrire avec le PUT,un panel complet, du genre : ça ça marche pas : local Panel = api.get("/panels/sprinklers/3") Panel.name = 'toto' api.put("/panels/sprinklers/3", Panel) mais ça oui : api.put("/panels/sprinklers/3", {name='toto'})
-
alors je me réponds tout seul, mais c'est étrange... voilà ce qui marche : local Liste = api.get("/panels/sprinklers/3").days table.remove(Liste.days, 1) local temp = json.encode(Liste) api.put("/panels/sprinklers/3", {days=json.decode(temp)}) faut passer par une variable intermédiaire !!?? !!??
-
Alors je me rends compte que le api.get ne mets pas tous les éléments tu tableaux dans le même ordre que l'on peut voir dans le Swagger. Mais le contenu est juste !! Alors je sais pas si ça a de l'importance !?
-
Bonsoir à tous, J'avais déjà posté une question sur le PUT dans l'API... (avec le panneau de chauffage) Et je rencontre la même chose avec le panneau GARDEN... Et j'obtiens le même résultat si je passe par le SWAGGER ! Soit je fais mal quelque chose (ce qui est certainement le cas) soit la HC3 bloque les PUT (j'en doute)... Voici un exemple : je veux modifier la liste des jours du panneau GARDEN. local Liste = api.get("/panels/sprinklers/3") print("Liste des jours initiale = "..json.encode(Liste.days)) table.remove(Liste.days, 1) print("Liste des jours modifiée = "..json.encode(Liste.days)) print("Résutat du PUT = "..api.put("/panels/sprinklers/3", Liste).reason) voici le debug : [DEBUG] 27.03.2020 23:08:57: Liste des jours initiale = ["monday","wednesday","friday","sunday"] [DEBUG] 27.03.2020 23:08:57: Liste des jours modifiée = ["wednesday","friday","sunday"] [DEBUG] 27.03.2020 23:08:57: Résutat du PUT = http://{$gateway-ip}/json-schema/panels/sprinklers/PUT_sprinklers.json. Invalid schema: #. Invalid keyword: additionalProperties. Invalid document: #/id Il me répond donc qu'il y a un soucis avec le schémas, donc le JSON que je lui transmet... Mais je comprends pas, je ne touche pas au JSON, puisque je travail directement avec la table ?? vous avez une idée ?
-
ben !!! ça marche !! et avec un simple \n !!! Mais je le fais pas depuis la scène d'origine... pour tant quand j'ai décrit le sujet, je créais une string de la sorte : ListeSensorOpen = ListeSensorOpen..SensorName.." dans "..RoomName.."\n" et j'envoie comme ça : fibaro.call(435, "SendProwl", 0,"HC3","Warning","Doors/Windows Open : "..ListeSensorOpen) c'est la que je me suis rendu compte du problème... Bon je teste demain dans les conditions réelles c'est compliqué d’essayer de le simuler dans la scène d'origine du problème... (obliger d'ouvrir les fenêtres pendant 1/2 heure, et la ça caille...) je te confirme demain...
-
ah mince non ! attend...
-
alors si y a 2 ou 3 variables, ça passe. Mais j'ai un QA ou il y en a 10, et je peux plus en ajouter une
-
allé je continue : ça c'est vraiment pénible par contre... quand je veux ajouter une nouvelle variable à un QA, si il en existe déjà, j'ai un message d'erreur qui m'empêche de sauvegarder la création de la nouvelle :
-
it's OK ! excuse me ! I have 3 access points and I did a loop for each AP. between each AP, I close the socket to open again on an another IP. And the AP doesn't like that So i don't close the socket and the command : SELF.soc:connect(SELF.ListeAP[SELF.NumberAP],23 ,{ ... ........ works fine still. PFFFFFFFFFFIIIIIIIIOOOOOOOUUUUUUU ! super ! thanks ! I must write any comments to remember this method
-
So I have a problem with the last command : "save" save = function(arg) SELF.soc:write("save-and-activate".."\n",{ success=function(result) post({type='read', tag='SAVE : '},1000) end, error = function(msg) SELF:debug("Error:",msg) end }) end, I have not error message, but access point don't react ! I do the same instruction with HC2 and it works, there is no difference !!!
-
yes i set to 100 ms... But I have a problem with the last command "save" ! I think, it is not executed... I'm searching why...
-
but what is the difference between "SELF" and "self" ?
-
YEEEES !! it's fine !! thank you very much for your help ! it's not natural for me to programming like this but it's very interesting ! local handlers = nil function QuickApp:onInit() SELF = self SELF.soc = net.TCPSocket({timeout = 2000}) post({type='start'}) end function post(ev,time) setTimeout(function() SELF:debug("STEP:",ev.type) handlers[ev.type](ev) end, time or 100) end handlers={ start = function(ev) SELF.soc:connect("192.168.2.242",23 ,{ success = function(result) post({type='connected',res=result}) end, error = function(msg) SELF:debug("Error:",msg) end }) end, connected = function(ev) print("SUCCESS CONNECTION") post({type='read',tag="CONNECT RESULT:",next='login'}) end, login = function(ev) SELF.soc:write("admin".."\n",{ success=function(result) post({type='read', tag='LOGIN : ',next='password'}) end, error = function(msg) SELF:debug("Error:",msg) end }) end, password = function(ev) SELF.soc:write("xxxx".."\n",{ success=function(result) post({type='read', tag='PASSWORD RESULT : ',next='config'}) end, error = function(msg) SELF:debug("Error:",msg) end }) end, config = function(ev) SELF.soc:write("configure terminal".."\n",{ success=function(result) post({type='read', tag='CONFIG RESULT : ',next='status'}) end, error = function(msg) SELF:debug("Error:",msg) end }) end, status = function(ev) SELF.soc:write("radio 2.4 disable".."\n",{ success=function(result) post({type='read', tag='STATUS RESULT : ',next='exitMenu'}) end, error = function(msg) SELF:debug("Error:",msg) end }) end, exitMenu = function(ev) SELF.soc:write("exit".."\n",{ success=function(result) post({type='read', tag='EXIT RESULT : ',next='save'}) end, error = function(msg) SELF:debug("Error:",msg) end }) end, save = function(ev) SELF.soc:write("save-and-activate".."\n",{ success=function(result) post({type='read', tag='EXIT RESULT : '}) end, error = function(msg) SELF:debug("Error:",msg) end }) end, read = function(ev) SELF.soc:read({ success=function(result) SELF:debug(ev.tag,tostring(result)) if ev.next then post({type=ev.next}) end end, error = function(msg) SELF:debug("Error:",msg) end }) end, }
-
ok with this : post({type=ev.next})
-
I have a problem with the read function : read = function(ev) SELF.soc:read({ success=function(result) SELF:debug(ev.tag,tostring(result)) post(ev.next) end, error = function(msg) SELF:debug("Error:",msg) end }) end, the instruction "post()" seems not be called !
-
ah ok with this : local handlers = nil function QuickApp:onInit() SELF = self SELF.soc = net.TCPSocket({timeout = 2000}) post({type='start'}) end pfffffiou !!! I'm not used to doing with this methode. I will try...
-
hummm I have an error with the code : local SELF=self SELF,handlers = nil,nil function QuickApp:onInit() SELF.soc = net.TCPSocket({timeout = 2000}) post({type='start'}) end function post(ev,time) setTimeout(function() SELF:debug("STEP:",ev.type) handlers[ev.type](ev) end, time or 0) end handlers={ start = function(ev) SELF.soc.connect("192.168.2.242",23 ,{ success = function(result) print("2") post({type='connected',res=result}) end, error = function(msg) SELF:debug("Error:",msg) end }) end, ERROR : attempt to index a nil value (upvalue 'SELF')
-
Hello ! Voici une méthode d'un QA qui me permet d'activer ou désactiver un point d'accès wifi. Je pilote cet AP via le port 23 en telnet (CLI). Le côté asynchrone des socket me rend le code HORRIBLE !!! mais fonctionnel... Je n'avais pas ce soucis avec la HC2 car le tcpSocket:read() ou tcpSocket:write() n'était pas asycnhrone... y a t il moyen de simplifier cela ? attention, voilà le pavé : function QuickApp:SwitchOn() -- open connection to the device self.sock:connect(self:getVariable("IP"), 23, { success = function(result) print("SUCCES CONNECTION") --read response self:Read() --wait response fibaro.setTimeout(100, function() --wait response (3 s)... Timeout = os.time() + 3 while os.time() < Timeout do res = self:getVariable("Result") if res and res ~= "toto" then break end fibaro.sleep(1000) end print("RESULT - "..res) end) --WRITE LOGIN -------------------------------------------------------------------------------------------------------------------------- fibaro.setTimeout(100, function() self.sock:write("admin".."\n", { success = function(result) --read response self:Read() --wait response fibaro.setTimeout(1, function() --wait response (3 s)... Timeout = os.time() + 3 while os.time() < Timeout do res = self:getVariable("Result") if res and res ~= "toto" then break end fibaro.sleep(1000) end print("RESULT - "..res) --WRITE PASSWORD-------------------------------------------------------------------------------------------------------------------------- fibaro.setTimeout(100, function() self.sock:write("xxxxx".."\n", { success = function(result) --read response self:Read() --wait response fibaro.setTimeout(1, function() --wait response (3 s)... Timeout = os.time() + 3 while os.time() < Timeout do res = self:getVariable("Result") if res and res ~= "toto" then break end fibaro.sleep(1000) end print("RESULT - "..res) --WRITE configure terminal------------------------------------------------------------------------------------------------ fibaro.setTimeout(100, function() self.sock:write("configure terminal".."\n", { success = function(result) --read response self:Read() --wait response fibaro.setTimeout(1, function() --wait response (3 s)... Timeout = os.time() + 3 while os.time() < Timeout do res = self:getVariable("Result") if res and res ~= "toto" then break end fibaro.sleep(1000) end print("RESULT - "..res) --radio 2.4 enable/desable--------------------------------------------------------------------------------- fibaro.setTimeout(100, function() self.sock:write("radio 2.4 disable".."\n", { success = function(result) --read response self:Read() --wait response fibaro.setTimeout(1, function() --wait response (3 s)... Timeout = os.time() + 3 while os.time() < Timeout do res = self:getVariable("Result") if res and res ~= "toto" then break end fibaro.sleep(1000) end print("RESULT - "..res) --WRITE EXIT------------------------------------------------------------------------------- fibaro.setTimeout(100, function() self.sock:write("exit".."\n", { success = function(result) --read response self:Read() --wait response fibaro.setTimeout(1, function() --wait response (3 s)... Timeout = os.time() + 3 while os.time() < Timeout do res = self:getVariable("Result") if res and res ~= "toto" then break end fibaro.sleep(1000) end print("RESULT - "..res) --WRITE save-and-activate------------------------------------------------- fibaro.setTimeout(100, function() self.sock:write("save-and-activate".."\n", { success = function(result) --read response self:Read() --wait response fibaro.setTimeout(1, function() --wait response (3 s)... Timeout = os.time() + 3 while os.time() < Timeout do res = self:getVariable("Result") if res and res ~= "toto" then break end fibaro.sleep(1000) end print("RESULT - "..res) end) end, }) end) ------------------------------------------------- end) end, }) end) ------------------------------------------------- end) end, }) end) ----------------------------------------------------------------------------------------------------------- end) end, }) end) ---------------------------------------------------------------------------------------------------------------------------- end) end, }) end) ---------------------------------------------------------------------------------------------------------------------------- end) end, }) end) ---------------------------------------------------------------------------------------------------------------------------- end, error = function(err) self:debug(err) end }) end et voici le debug : on voit que tout ce passe bien [DEBUG] 26.03.2020 12:12:54: onUIEvent: {"elementName":"button1","eventType":"onReleased","deviceId":133,"values":[null]} [DEBUG] 26.03.2020 12:12:54: SUCCES CONNECTION [DEBUG] 26.03.2020 12:12:54: START READ... [DEBUG] 26.03.2020 12:12:54: RESULT - ������!���� login: [DEBUG] 26.03.2020 12:12:54: START READ... [DEBUG] 26.03.2020 12:12:54: RESULT - admin Password: [DEBUG] 26.03.2020 12:12:54: START READ... [DEBUG] 26.03.2020 12:12:54: RESULT - NetgearRdc# [DEBUG] 26.03.2020 12:12:55: START READ... [DEBUG] 26.03.2020 12:12:55: RESULT - configure terminal NetgearRdc(config)# [DEBUG] 26.03.2020 12:12:55: START READ... [DEBUG] 26.03.2020 12:12:55: RESULT - radio 2.4 disable NetgearRdc(config)# [DEBUG] 26.03.2020 12:12:55: START READ... [DEBUG] 26.03.2020 12:12:55: RESULT - exit NetgearRdc# [DEBUG] 26.03.2020 12:12:55: START READ... [DEBUG] 26.03.2020 12:12:55: RESULT - save-and-activate
-
mais est ce qu'il peut les piloter ?
-
I think, I find the solution : I had to put the whole loop in a setTimeout : -- init of Variable QA self:setVariable("Result", "toto") -- open connection to the device self.sock:connect(self:getVariable("IP"), 23, { success = function(result) self:debug("SUCCES CONNECTION") --read response self:Read() --wait response fibaro.setTimeout(10, function() --wait response (3 s)... Timeout = os.time() + 3 while os.time() < Timeout do res = self:getVariable("Result") --self:debug("VARIABLE = "..res) if res and res ~= "toto" then break end fibaro.sleep(1000) end self:debug("END LOOP - "..res) end) end, and the debug : [DEBUG] 26.03.2020 09:14:47: onUIEvent: {"elementName":"button1","eventType":"onReleased","deviceId":133,"values":[null]} [DEBUG] 26.03.2020 09:14:47: SUCCES CONNECTION [DEBUG] 26.03.2020 09:14:47: START READ... [DEBUG] 26.03.2020 09:14:47: END LOOP - ������!���� login:
-
I try to use a part of your method with another code, to do something else, but it doesn't work and I don't understand the result : I open a socket to Wireless device throught 23 port and I must receive a response... here is a part of the main code : -- init of Variable QA self:setVariable("Result", "toto") -- open connection to the device self.sock:connect(self:getVariable("IP"), 23, { success = function(result) self:debug("SUCCES CONNECTION") --read response self:Read() --wait response (3 s)... Timeout = os.time() + 3 while os.time() < Timeout do res = self:getVariable("Result") self:debug("VARIABLE = "..res) if res and res ~= "toto" then break end fibaro.sleep(1000) end self:debug("END LOOP - "..res) end, here is the function Read() : in the same QA function QuickApp:Read() self:debug("START READ...") self.sock:read({ success = function(result) self:setVariable("Result", result) self:debug("END READ - "..result) end, error = function(err) self:debug("READ ERROR - "..err) end }) end and now, the result in debug console : [DEBUG] 26.03.2020 08:47:35: onInit [DEBUG] 26.03.2020 08:47:37: onUIEvent: {"eventType":"onReleased","deviceId":133,"values":[null],"elementName":"button1"} [DEBUG] 26.03.2020 08:47:37: SUCCES CONNECTION [DEBUG] 26.03.2020 08:47:37: START READ... [DEBUG] 26.03.2020 08:47:37: VARIABLE = toto [DEBUG] 26.03.2020 08:47:38: VARIABLE = toto [DEBUG] 26.03.2020 08:47:39: VARIABLE = toto [DEBUG] 26.03.2020 08:47:40: END LOOP - toto [DEBUG] 26.03.2020 08:59:08: END READ - ������!���� login: I don't understand why, "END READ - OK" is in the end !!! it should be before "END LOOP" !!!! and the result should be normally : "������!���� login:" I have the impression that, "self.sock:read" is blocked during the loop in the main. And the variable is not update. I try with to call Read() with a setTimeout(), but it's worse... I try with a Global Variable, but it's the same result... I try with a variable declared in the QA with self.xxx, but same... do you have an idea ? edit : if I delete the loop : it's ok, but maybe I don't receive the response in times... I would like to keep the timeout loop... but how ? [DEBUG] 26.03.2020 09:01:53: SUCCES CONNECTION [DEBUG] 26.03.2020 09:01:53: START READ... [DEBUG] 26.03.2020 09:01:53: END READ - ������!���� login:
-
thanks, I will study that...
-
il me semble que tu peux créer un utilisateur supplémentaire sur la box. en lui donnant les droit d’accès à tel ou tel device. sur le téléphone, tu utilises ce user là.
-
Je confirme qu'il n'y a pas d'interface navigateur "allégée". Moi qui arrive tout doucement au bout de la migration, je dois avouer que je ne me sers quasiment pas de l'application téléphone. Celle du navigateur permet de faire les réglages et la programmation. Je trouve qu'elle est correcte (à quelques petits bug près, n’empêchant en rien le déploiement et qui seront très certainement corrigés). Après le but de la domotique est d'automatiser les tâches, donc avec le moins d'interaction possible... Sinon, faut comme moi, créer sa propre interface, mais c'est un boulo de dingue ! Mais au moins tu as ce que tu veux, comme tu veux... En effet il y a des petites choses, mais c'est pas bloquant. Quand tu le sais, tu l'anticipes J'ai presque fini et je dois avouer que rien que les QA permettent d'économiser beaucoup beaucoup de ligne de codes... Après il manque certaines fonctionnalités particulières, qui arriveront... peut-être, j'espère... !! qui pour la majorité des utilisateurs, n'a pas d'importance... Perso, pour le moment, je suis complètement satisfait de cette box !
-
Bon ben j'ai du modifier le mot de passe du user de GGH dans la HC3. bref, là ça marche... Mais j'ai vraiment pas souvenir d'avoir fait ça... bref.