
jjacques68
Membres confirmés-
Compteur de contenus
4 364 -
Inscription
-
Dernière visite
-
Jours gagnés
39
Tout ce qui a été posté par jjacques68
-
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.
-
ah punaise nan ! J'ai une erreur 401 sur IFTTT !! depuis le 22 mars ! Mais j'ai rien modifié niveau droits d'accès ou autres sur le HC3 !
-
Hello tout le monde : Voici un exemple de ce que j'ai fais pour pouvoir désactiver ou activer les notifications de nos précieux device. Dans mon cas, je ne vois pas l'intérêt de recevoir les notifications si on est présent à la maison (surtout en ce moment)... A la fin de la journée, ça monte à plusieurs centaines quand même ! Donc l'idée était de créer un QA pour tout désactiver ou tout activer. PRÉREQUIS : configurer vos notifications quand même au moins une fois pour chaque device (c'est du boulo...) exemple pour une lampe : (perso je n'utilise que les notification push, jamais les mail...) CREATION DU QA DE COMMANDE : fichier téléchargeable à la fin du tuto... on y voit 2 boutons, enable et desable. et voici le code... pas très compliqué : ------------------------------------------------------------------------------------------------- -- V1 - 25/03/2020 - Active/désactive les notifications push ------------------------------------------------------------------------------------------------- function QuickApp:onInit() self.ListeEvent = { "IsOpening", --Volet ouvert "IsClosing", --Volet fermé "TurningOn", --lumière ON "TurningOff", --lummière OFF "Motion", --détection PIR "Flood", --détection inondation "Opening", --ouverture d'une porte/fenêtre } end function QuickApp:turnOn() self:updateProperty("value", true) self:UpdateNotif(true) end function QuickApp:turnOff() self:updateProperty("value", false) self:UpdateNotif(false) end -------------------------------------------------------- -- Modifie l'API suivant l'argument true ou false -------------------------------------------------------- function QuickApp:UpdateNotif(value) --liste tous les device VISIBLE ListeDevice = api.get("/devices/?visible=true") --pour chaque device trouvés for i = 1, #ListeDevice do --récupère les notifications de ce device MyNotif = api.get("/deviceNotifications/v1/"..ListeDevice[i].id) --pour chaque notif de ce device for j = 1, #MyNotif do --teste pour chaque Evenement for k,v in pairs(self.ListeEvent) do --si l'évenement est trouvé, on modifie if v == MyNotif[j].type then MyNotif[j].active = value end end end --applique les modifications pour ce device api.put("/deviceNotifications/v1/"..ListeDevice[i].id, MyNotif) end self:debug("Notification = "..tostring(value)) end UTILISATION : pour utiliser ce QA dans nos applications : il suffit de l'appeler avec la commande suivante : (attention l'ID est celui du QA commande, = 438 chez moi) fibaro.call(438, "turnOn") fibaro.call(438, "turnOff") Voilà tout ! C'est tout simple. on pourrait imaginer des futurs améliorations, comme par exemple mettre une liste d'exclusion, si l'on veut quand même garder certaine notification... Merci à @Krikroff qui m'a aidé à trouver les infos à modifier dans l'API. FICHIERS : Enable_Push.fqa
-
Alors encore un petit bug : Constater après avoir créé un QA de notification PROWL. En effet, j'appelle une méthode de cette façon : fibaro.call(ID, "SendProwl", Priority, Application, Event, Description) si dans la chaine "Description", il y a un "\n" donc retour chariot, la commande est simplement ignorée La méthode n'est pas exécutée. Je peux lui mettre n'importe quoi dans la ligne, même une méthode qui n'existe pas (où normalement on a un message d'erreur), il l'ignore. je souhaitais m'en servir car, dans une scène, je personnalise le message. Et il se peut que j'ai plusieurs lignes avec retour chariot.
-
en fait je pense plutôt au lien google home et IFTTT qui plante... pourtant sur mon compte IFTTT tout semble ok. ça marchait nickel il y a 3 jours !
-
j’ai pas de solutions, mais je souhaite suivre la discution...
- 10 réponses
-
- certificat
- synology
-
(et 1 en plus)
Étiqueté avec :
-
Bon ben va pour une VG alors c'est un peu dommage... Merci !!
-
Hello tout le monde. Je souhaite modifier un panneau de chauffage (enfin maintenant appelé "PanelClimate"...) Voilà ce que je fais, mais mes modifications ne sont pas prise en compte ??? --lecture du panneau Climate RoomClimatePanel = api.get("/panels/climate/"..RoomClimatePanelId) --modification du panneau RoomClimatePanel.properties.currentTemperatureHeating = 4 RoomClimatePanel.mode = "Off" api.put("/panels/climate/"..RoomClimatePanelId, RoomClimatePanel) --confirmation RoomClimatePanel = api.get("/panels/climate/"..RoomClimatePanelId) print(json.encode(RoomClimatePanel)) j'ai pas d'erreur, mais visiblement le PUT n'applique pas les modifications... une idée ?? merciiiiii !
-
hello ! votre google home fonctionne en ce moment ? moi il me répond mais pas d’actions...
-
nan mais attend ! ils interdisent les marché niveau état, mais laisse les préfets ou maires prendre les libertés de les maintenir ! comment se décharger de la responsabilité ! ma-gni-fi-que !
-
nan mais c’est énorme ce que raconte le gouvernement !!! désolé fallait que ça sorte.
-
Hello ! Petite question : est-il possible qu'un QA renvoie une valeur suite à son appelle ? Voici un exemple tout bête : function QuickApp:MyFunction() return "toto" end et voici son appel : MonRetour = fibaro.call(xx, "MyFunction) Mais visiblement ça marche pas Alors pour des retours de type : boolean, il suffit d'utiliser un QA de type binarySensor/Switch numérique, il faut utiliser un QA de type multilevelSensor/Switch string ????? J'ai bien tenté d'utiliser des QA de type générique, mais ils ne proposent pas la propriété "value" !
-
ah oui ok, je ferai plus attention... ça va être hors sujet du topic, désolé, mais à quoi servent les étiquettes que l'on met ? comme pour cette exemple (notification, api, ...)