Barelle Posté(e) le 31 octobre 2019 Signaler Posté(e) le 31 octobre 2019 Oui, la HC2 envoie des données à Node-RED en utilisant le un PUT du protocole http.
971jmd Posté(e) le 1 novembre 2019 Auteur Signaler Posté(e) le 1 novembre 2019 aaaaaaa ok j' ai tester comme ça mai ça fonctionne +/- bien, j'ai la remonter d'information mai j'ai un message d'erreur du cotée de fibaro --[[ %% autostart %% properties 33 power %% events %% globals --]] local urlNodeRed = "http://192.168.0.31:1880/HC2/Data/ModuleX"; -- Node-RED serveur local HTTPClientTimeout = 15000; function sendValueToNodeRed(payload) local nodeRed = net.HTTPClient(); nodeRed:request(urlNodeRed, { options = {method = 'PUT', data = payload, headers = {["content-type"] = "text/plain"}, timeout = HTTPClientTimeout}, success = function(response) fibaro:debug("sendValueToNodeRed>>>success, payload="..payload); end, error = function (err) fibaro:debug("sendValueToNodeRed>>>error:" .. err .. ", payload=" .. payload); if string.lower(err) == "operation cancelled" then HTTPClientTimeout = HTTPClientTimeout + 1000; fibaro:debug("sendValueToNodeRed>>>error:operation cancelled, increasing HTTPClientTimeout to " .. HTTPClientTimeout .. ", payload=" .. payload); else fibaro:debug("sendValueToNodeRed>>>error:" .. err .. ", payload=" .. payload); end end }); end -- sendValueToNodeRed ---value = tostring(20); value = fibaro:getValue(33, "power") sendValueToNodeRed(value); et le message erreur [DEBUG] 21:18:41: sendValueToNodeRed>>>error:Operation canceled, payload=0 [DEBUG] 21:18:41: sendValueToNodeRed>>>error:Operation canceled, payload=0 [DEBUG] 21:19:34: sendValueToNodeRed>>>error:Operation canceled, payload=2.9 [DEBUG] 21:19:34: sendValueToNodeRed>>>error:Operation canceled, payload=2.9 [DEBUG] 21:19:35: sendValueToNodeRed>>>error:Operation canceled, payload=8.1 [DEBUG] 21:19:35: sendValueToNodeRed>>>error:Operation canceled, payload=8.1 [DEBUG] 21:21:16: sendValueToNodeRed>>>error:Operation canceled, payload=33 [DEBUG] 21:21:16: sendValueToNodeRed>>>error:Operation canceled, payload=33 [DEBUG] 21:21:21: sendValueToNodeRed>>>error:Operation canceled, payload=45.8 [DEBUG] 21:21:21: sendValueToNodeRed>>>error:Operation canceled, payload=45.8 [DEBUG] 21:22:13: sendValueToNodeRed>>>error:Operation canceled, payload=40.3 [DEBUG] 21:22:13: sendValueToNodeRed>>>error:Operation canceled, payload=40.3 [DEBUG] 21:22:17: sendValueToNodeRed>>>error:Operation canceled, payload=26.2 [DEBUG] 21:22:17: sendValueToNodeRed>>>error:Operation canceled, payload=26.2 [DEBUG] 21:22:43: sendValueToNodeRed>>>error:Operation canceled, payload=46.5 [DEBUG] 21:22:43: sendValueToNodeRed>>>error:Operation canceled, payload=46.5
Barelle Posté(e) le 1 novembre 2019 Signaler Posté(e) le 1 novembre 2019 Cela fonctionne, bravo ! Les erreurs affichées par la HC2 viennent du fait que Node-RED n'acquitte pas le message ce qui correspond à cette partie du schéma qui permet de renvoyer un code http 204 à la hcé pour indiquer que le message est reçu est traité : avec : et send ack étant juste un envoi http.
971jmd Posté(e) le 1 novembre 2019 Auteur Signaler Posté(e) le 1 novembre 2019 salut OK pour le edit change node, mai pour le SEND c'est une Get et quel URL
Barelle Posté(e) le 1 novembre 2019 Signaler Posté(e) le 1 novembre 2019 euh, c'est un send... Il n'y a besoin d'aucun paramétrage !
971jmd Posté(e) le 1 novembre 2019 Auteur Signaler Posté(e) le 1 novembre 2019 J’ai toujours le message d’erreur
971jmd Posté(e) le 2 novembre 2019 Auteur Signaler Posté(e) le 2 novembre 2019 effectivement je me suis trompée si noin le code lua peut supporté un ou plusieurs module ? ou il faut crée un code par module
971jmd Posté(e) le 12 novembre 2019 Auteur Signaler Posté(e) le 12 novembre 2019 (modifié) salut @Barelle help help j'ai modifier le code qui est maintenant censé envoyer 2 informations au node-red du cotée FIBARO je pense que c’est ok enfin le code fonctionne, mai du cotée Node-red je n’arrive pas dans un 1er temps a afficher dans le debug les 2 valeurs (la valeur 1= la consommation et valeur 2 = si allumée=1 ou éteint=0 merci d'avance pour ton aide --[[ %% autostart %% properties 14 power %% events %% globals --]] local urlNodeRed = "http://192.168.0.31:1880/HC2/Data/ModuleXX"; -- Node-RED serveur local HTTPClientTimeout = 15000; function sendValueToNodeRed(payload) function sendValueToNodeRed2(payload2) local nodeRed = net.HTTPClient(); nodeRed:request(urlNodeRed, { options = {method = 'PUT', data = payload, headers = {["content-type"] = "text/plain"}, timeout = HTTPClientTimeout}, options = {method = 'PUT', data = payload2, headers = {["content-type"] = "text/plain"}, timeout = HTTPClientTimeout}, success = function(response) fibaro:debug("sendValueToNodeRed>>>success, payload="..payload); fibaro:debug("sendValueToNodeRed2>>>success, payload2="..payload2); end, error = function (err) fibaro:debug("sendValueToNodeRed>>>error:" .. err .. ", payload=" .. payload); if string.lower(err) == "operation cancelled" then HTTPClientTimeout = HTTPClientTimeout + 1000; fibaro:debug("sendValueToNodeRed>>>error:operation cancelled, increasing HTTPClientTimeout to " .. HTTPClientTimeout .. ", payload=" .. payload); else fibaro:debug("sendValueToNodeRed>>>error:" .. err .. ", payload=" .. payload); end end }); end -- sendValueToNodeRed end ---value2 = tostring(20); value = fibaro:getValue(14, "power") ---value = fibaro:getValue(511, "ui.Label1.value") sendValueToNodeRed(value); local value2 = fibaro:getValue(14, "value") sendValueToNodeRed2(value2); [DEBUG] 18:36:48: sendValueToNodeRed>>>success, payload=9.2 [DEBUG] 18:36:49: sendValueToNodeRed2>>>success, payload2=1 [{"id":"a936ee02.0b92f","type":"http in","z":"7ba69055.cc9f1","name":"","url":"/HC2/Data/ModuleX","method":"put","upload":false,"swaggerDoc":"","x":210,"y":120,"wires":[["c3af51d5.16976","6ebb8178.e8711","4779e702.a25d58"]]},{"id":"6ebb8178.e8711","type":"debug","z":"7ba69055.cc9f1","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":809.0000076293945,"y":171.59026908874512,"wires":[]},{"id":"4779e702.a25d58","type":"ui_gauge","z":"7ba69055.cc9f1","name":"","group":"441e46b9.f10ee8","order":17,"width":3,"height":2,"gtype":"gage","title":"AZERTY","label":"W","format":"{{value}}","min":0,"max":"1500","colors":["#00b500","#e6e600","#ca3838"],"seg1":"300","seg2":"800","x":760,"y":100,"wires":[]},{"id":"c3af51d5.16976","type":"change","z":"7ba69055.cc9f1","name":"ack","rules":[{"t":"set","p":"statusCode","pt":"msg","to":"204","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"\"\"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":174.0103874206543,"y":200.36458110809326,"wires":[["76dab5e4.a1a81c"]]},{"id":"76dab5e4.a1a81c","type":"http response","z":"7ba69055.cc9f1","name":"","statusCode":"","headers":{},"x":314.00001525878906,"y":202.49998474121094,"wires":[]},{"id":"441e46b9.f10ee8","type":"ui_group","z":"","name":"Gestion des PORTAILS","tab":"15e18774.f16959","order":1,"disp":true,"width":15,"collapse":false},{"id":"15e18774.f16959","type":"ui_tab","z":"","name":"F I B A R O","icon":"dashboard","order":9,"disabled":false,"hidden":false}] Modifié le 12 novembre 2019 par 971jmd
971jmd Posté(e) le 12 novembre 2019 Auteur Signaler Posté(e) le 12 novembre 2019 (modifié) en 2ème temps je cherche a FONCTION d'avoir 2 sorties, une pour la conso et l'autre pour si ON/OFF et 3ème exploitée le ( node-red-contrib-ui-svg 1.2 ) qui fonctionne bien avec fibaro, un clic sur l'ampoule ma lampe s'allume et 2 clic elle s’éteint mai je n'est pas le retour d'état Modifié le 12 novembre 2019 par 971jmd
971jmd Posté(e) le 13 mai 2020 Auteur Signaler Posté(e) le 13 mai 2020 (modifié) salut, De retour sur Node J'ai une question quel solution pour exemple réglée l'heure depuis le dashbord ? merci d'avance [{"id":"c128e04e.86c46","type":"ui_switch","z":"5f9c36c8.e8eaf8","name":"","label":"Eclairage Avant","tooltip":"","group":"2982e914.063116","order":8,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"55=ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"55=OFF","offvalueType":"str","officon":"","offcolor":"","x":380,"y":160,"wires":[[]]},{"id":"307989ff.110716","type":"ui_switch","z":"5f9c36c8.e8eaf8","name":"","label":"Eclairage facade 7","tooltip":"","group":"2982e914.063116","order":7,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"54=ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"54=OFF","offvalueType":"str","officon":"","offcolor":"","x":390,"y":100,"wires":[[]]},{"id":"cd5d3fb.fcaffc","type":"eztimer","z":"5f9c36c8.e8eaf8","name":"Horloge","debug":false,"autoname":"19:03 - 19:04","tag":"","suspended":false,"sendEventsOnSuspend":false,"lat":"","lon":"","timerType":"1","startupMessage":true,"ontype":"2","ontimesun":"dawn","ontimetod":"19:03","onpropertytype":"msg","onproperty":"payload","onvaluetype":"str","onvalue":"55=ON","onoffset":0,"onrandomoffset":0,"onsuppressrepeats":false,"offtype":"2","offtimesun":"dusk","offtimetod":"19:04","offduration":"20:08","offpropertytype":"msg","offproperty":"payload","offvaluetype":"str","offvalue":"55=OFF","offoffset":0,"offrandomoffset":0,"offsuppressrepeats":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":140,"y":160,"wires":[["c128e04e.86c46"]]},{"id":"7dd2a883.8006f8","type":"eztimer","z":"5f9c36c8.e8eaf8","name":"Horloge1","debug":false,"autoname":"23:20 - sunrise","tag":"","suspended":false,"sendEventsOnSuspend":false,"lat":"16.265","lon":"-61","timerType":"1","startupMessage":true,"ontype":"2","ontimesun":"dawn","ontimetod":"23:20","onpropertytype":"msg","onproperty":"payload","onvaluetype":"str","onvalue":"54=ON","onoffset":"","onrandomoffset":0,"onsuppressrepeats":false,"offtype":"1","offtimesun":"sunrise","offtimetod":"\"2\"","offduration":"22:18","offpropertytype":"msg","offproperty":"payload","offvaluetype":"str","offvalue":"54=OFF","offoffset":0,"offrandomoffset":0,"offsuppressrepeats":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":140,"y":100,"wires":[["307989ff.110716"]]},{"id":"2982e914.063116","type":"ui_group","z":"","name":"Gestion des Portails et éclairages","tab":"9d283cc0.2eddf","order":1,"disp":true,"width":"6","collapse":false},{"id":"9d283cc0.2eddf","type":"ui_tab","z":"","name":"GEDICO","icon":"dashboard","order":1,"disabled":false,"hidden":false}] Modifié le 13 mai 2020 par 971jmd
Messages recommandés