I am not sure if this is the right way to reset msg.headers if you use 2 nodes in one flow.
I am having problems to get my flow running.
It is one way.
The other is to use the built in form on the Http-Request node
You will have to provide more info i am afraid.
Have you attached a debug node - (debug node set to show the complete msg) - to the output of that change
node & inspected what is going into the http-request node?
Hallo Steve,
I am using this flow Netatmo Flow library and it runs perfectly .
But I want to link it to my central HTTP-request using link-nodes in stead of the existing http-requests. Most probabely I am having problems to put the correct parameters into the change node in front of the link call. Pleas have a look at the flow.
Looking at an existing flow, Created 11 months, 3 weeks ago that clearly worked for the user who posted it is not going to help me help you - i have no idea what happens in your Node-RED inside the target link-in--flow--link-return!
Start simple. Does the demo flow actually work ?
yes, the flow works. But I have many request nodes in my application on a RPI. Having a central request serializes the requests and avoids network overloads. This is why a want to run it through the central request.
The central request works already with the ohter request successfuly.
Then so long as your super team doesn't change or delete headers, then it should just simply work.
As I said before....
Finaly the working NetAtmo flow with single HTTP request
[{"id":"5dfd7c4fa8812f8b","type":"tab","label":"Netatmo New","disabled":false,"info":"","env":[]},{"id":"37c406c4251df006","type":"group","z":"5dfd7c4fa8812f8b","name":"retrieve data from Net Atmo","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["227b570a0ddb37d6","c90883e30af7414f","a6497c641eae2d3d","f03d6a1770671654","43cea1af6281e150","4272b4f37aaa8d85","d705af61f82a51a0","ccf05151b8977a17","b2aee11227c34965","06d4b90b7b3e2087","ead7a83a276da6d5","5b801eefb73d69e8","cbac66eef3ac6f68","f64a1f7a539e19ae","d09a9e75c1cb3fd9","39c95ea1197778ad"],"x":74,"y":579,"w":1792,"h":382},{"id":"1e6ac73d16d3e4fd","type":"group","z":"5dfd7c4fa8812f8b","name":"start and refresh access data","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["35b6ddece06e5a06","d273766e96d450e0","6ceb42cb69397e82","6247f8cc1cc3880c","fe38821d7708d05c","5d156d10e7192948","f4794e23ba9db104","a6e99594aa88149d","549a3c451e797ba0","a2a6fbccd8054ab7","fde679bf6c4b3a78","b50c27c613f7bfda","37572cdd83c4a88e"],"x":74,"y":339,"w":1632,"h":202},{"id":"f1d3eb19dd08efed","type":"group","z":"5dfd7c4fa8812f8b","name":"set NetAtmo credetials","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["033f7ad3bdf1e1f8","7537a9afc9d0ce1a"],"x":74,"y":99,"w":492,"h":82},{"id":"7bdfafd0d061bf13","type":"group","z":"5dfd7c4fa8812f8b","name":"single HTTP request","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["472e545334afadc6","2df1498ab5d28910","424bd2e4540e6da0"],"x":84,"y":219,"w":402,"h":82},{"id":"75adeef4d28b4d5f","type":"group","z":"5dfd7c4fa8812f8b","name":"error handling","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["c3d6f0104c69996d","1fc4771ca6ce3334","97d79dc47576aa9f","d92a122a85e3b0cc","653ae61d5333b989","bb043a8f9a80d5ea"],"x":74,"y":999,"w":732,"h":122},{"id":"b50c27c613f7bfda","type":"junction","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","x":500,"y":380,"wires":[["d273766e96d450e0"]]},{"id":"35b6ddece06e5a06","type":"inject","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"Start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":170,"y":380,"wires":[["b50c27c613f7bfda"]]},{"id":"d273766e96d450e0","type":"change","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"Set param request & refresh","rules":[{"t":"set","p":"method","pt":"msg","to":"POST","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"https://api.netatmo.com/oauth2/token","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"grant_type\":\"refresh_token\",\"refresh_token\":$globalContext(\"NetatmoRefreshToken\"),\"client_id\":$globalContext(\"NetatmoClientId\"),\"client_secret\":$globalContext(\"NetatmoClientSecret\")}","tot":"jsonata"},{"t":"set","p":"headers[\"content-type\"]","pt":"msg","to":"application/x-www-form-urlencoded","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":440,"wires":[["37572cdd83c4a88e"]]},{"id":"6ceb42cb69397e82","type":"change","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"Store tokens & delay","rules":[{"t":"set","p":"NetatmoAccessToken","pt":"global","to":"payload.access_token","tot":"msg"},{"t":"set","p":"NetatmoRefreshToken","pt":"global","to":"payload.refresh_token","tot":"msg"},{"t":"set","p":"delay","pt":"msg","to":"payload.expires_in*1000-300000","tot":"jsonata"},{"t":"set","p":"status","pt":"msg","to":"OK","tot":"str"},{"t":"set","p":"NetatmoLastUpdateTime","pt":"global","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":380,"wires":[["f4794e23ba9db104","a6e99594aa88149d"]]},{"id":"033f7ad3bdf1e1f8","type":"change","z":"5dfd7c4fa8812f8b","g":"f1d3eb19dd08efed","name":"Set Netatmo Creds & Tokens","rules":[{"t":"set","p":"NetatmoClientId","pt":"global","to":"","tot":"str"},{"t":"set","p":"NetatmoClientSecret","pt":"global","to":"","tot":"str"},{"t":"set","p":"NetatmoAccessToken","pt":"global","to":"581352d2e6da23fa898b49ae|f849008b26ca2aeb84a459cea673f283","tot":"str"},{"t":"set","p":"NetatmoRefreshToken","pt":"global","to":"581352d2e6da23fa898b49ae|fe902827ce3f122f9b0840592c3334b2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":140,"wires":[[]]},{"id":"7537a9afc9d0ce1a","type":"inject","z":"5dfd7c4fa8812f8b","g":"f1d3eb19dd08efed","name":"Set first info","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":140,"wires":[["033f7ad3bdf1e1f8"]]},{"id":"6247f8cc1cc3880c","type":"inject","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"Stop","props":[{"p":"reset","v":"1","vt":"num"},{"p":"status","v":"STOP","vt":"str"},{"p":"delay","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":480,"wires":[["f4794e23ba9db104","fde679bf6c4b3a78"]]},{"id":"fe38821d7708d05c","type":"switch","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"All ok ?","property":"payload","propertyType":"msg","rules":[{"t":"hask","v":"access_token","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1040,"y":440,"wires":[["6ceb42cb69397e82"],["5d156d10e7192948"]],"outputLabels":["Response OK","Error"]},{"id":"5d156d10e7192948","type":"change","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"Delay 1 hour on error","rules":[{"t":"set","p":"delay","pt":"msg","to":"3600000","tot":"num"},{"t":"set","p":"status","pt":"msg","to":"KO","tot":"str"},{"t":"set","p":"NetatmoLastUpdateTime","pt":"global","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":500,"wires":[["f4794e23ba9db104","a6e99594aa88149d"]]},{"id":"f4794e23ba9db104","type":"delay","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"Refresh","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":440,"y":440,"wires":[["d273766e96d450e0"]]},{"id":"a6e99594aa88149d","type":"delay","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":1600,"y":420,"wires":[["549a3c451e797ba0"]]},{"id":"549a3c451e797ba0","type":"function","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"Next refresh in...","func":"var d = new Date();\nvar n = d.getTime();\nvar start_time = global.get('NetatmoLastUpdateTime')||0;\nvar duration = msg.delay/1000;\nvar elapsed_time = Math.round((n - start_time)/1000);\n\nvar remains = new Date(null);\nremains.setSeconds(duration - elapsed_time); // specify value for SECONDS here\nvar remains_h = remains.toISOString().substr(11, 8);\nif (msg.status == \"STOP\") {\n node.status({});\n msg.remains = \"00:00:00\";\n msg.payload = 0;\n return [null, msg];\n}\nif (elapsed_time < duration) {\n node.status({fill:msg.status == \"OK\" ? \"blue\" : \"red\",shape:\"dot\", text:remains_h});\n msg.remains = remains_h;\n return [ msg, null ];\n}\n\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1600,"y":480,"wires":[["a6e99594aa88149d"],[]]},{"id":"227b570a0ddb37d6","type":"change","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"set pram request","rules":[{"t":"set","p":"method","pt":"msg","to":"GET","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"https://api.netatmo.com/api/getstationsdata","tot":"str"},{"t":"set","p":"headers[\"Authorization\"]","pt":"msg","to":"\"Bearer \" & $globalContext(\"NetatmoAccessToken\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":760,"wires":[["d09a9e75c1cb3fd9"]]},{"id":"c90883e30af7414f","type":"inject","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"Get Netatmo Data","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":false,"onceDelay":"10","topic":"","payload":"","payloadType":"date","x":210,"y":760,"wires":[["227b570a0ddb37d6"]]},{"id":"a6497c641eae2d3d","type":"mqtt in","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"","topic":"Net_Atmo_record","qos":"0","datatype":"auto-detect","broker":"99603ece.52e2a","nl":false,"rap":true,"rh":0,"inputs":0,"x":1520,"y":740,"wires":[["f03d6a1770671654"]]},{"id":"f03d6a1770671654","type":"debug","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"netatmo record in","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1730,"y":740,"wires":[]},{"id":"43cea1af6281e150","type":"inject","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"Test","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":820,"wires":[["227b570a0ddb37d6"]]},{"id":"a2a6fbccd8054ab7","type":"link in","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"stop-in","links":["fde679bf6c4b3a78"],"x":1335,"y":440,"wires":[["a6e99594aa88149d","549a3c451e797ba0"]]},{"id":"fde679bf6c4b3a78","type":"link out","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"stop-out","mode":"link","links":["a2a6fbccd8054ab7"],"x":395,"y":500,"wires":[]},{"id":"4272b4f37aaa8d85","type":"switch","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"body?","property":"payload","propertyType":"msg","rules":[{"t":"hask","v":"body","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":930,"y":760,"wires":[["b2aee11227c34965","ccf05151b8977a17","d705af61f82a51a0","5b801eefb73d69e8","ead7a83a276da6d5"],["39c95ea1197778ad"]]},{"id":"d705af61f82a51a0","type":"mqtt out","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"Net_Atmo_record","topic":"Net_Atmo_record","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"99603ece.52e2a","x":1270,"y":740,"wires":[]},{"id":"5b801eefb73d69e8","type":"link out","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"link out 2","mode":"link","links":["9ceca7067dab4533","f122c9b8706c128b"],"x":1195,"y":800,"wires":[]},{"id":"ccf05151b8977a17","type":"function","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"time / record counter","func":"let counter = context.get(\"counter\");\ncounter = counter + 1;\ncontext.set(\"counter\", counter);\n\nlet time = moment().tz(\"Europe/Berlin\").format(\"HH:mm:ss\");\nnode.status({ fill: \"green\", shape: \"dot\", text: time + \" / \" + counter });\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\n\ncontext.set(\"counter\", 0);\n","finalize":"","libs":[{"var":"moment","module":"moment"},{"var":"momentTimezone","module":"moment-timezone"}],"x":1280,"y":680,"wires":[[]]},{"id":"ead7a83a276da6d5","type":"trigger","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"watchdog","op1":"","op2":"","op1type":"nul","op2type":"date","duration":"20","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1240,"y":840,"wires":[["cbac66eef3ac6f68"]]},{"id":"f64a1f7a539e19ae","type":"link out","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"link out 258","mode":"link","links":["4aa91ee5.08bf2"],"x":1485,"y":840,"wires":[]},{"id":"cbac66eef3ac6f68","type":"function","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"watchdog","func":"let text = \"NetAtmo länger als 20 min offline!\";\nreturn { payload: { 'room': 'error', 'value': text } };","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1380,"y":840,"wires":[["f64a1f7a539e19ae"]]},{"id":"b2aee11227c34965","type":"debug","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"status","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload.status","targetType":"msg","statusVal":"payload.status","statusType":"auto","x":1230,"y":620,"wires":[]},{"id":"06d4b90b7b3e2087","type":"switch","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"object?","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"object","vt":"object"},{"t":"istype","v":"string","vt":"string"}],"checkall":"true","repair":false,"outputs":2,"x":800,"y":760,"wires":[["4272b4f37aaa8d85"],[]]},{"id":"472e545334afadc6","type":"http request","z":"5dfd7c4fa8812f8b","g":"7bdfafd0d061bf13","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":270,"y":260,"wires":[["424bd2e4540e6da0"]]},{"id":"2df1498ab5d28910","type":"link in","z":"5dfd7c4fa8812f8b","g":"7bdfafd0d061bf13","name":"request_in","links":[],"x":125,"y":260,"wires":[["472e545334afadc6"]]},{"id":"424bd2e4540e6da0","type":"link out","z":"5dfd7c4fa8812f8b","g":"7bdfafd0d061bf13","name":"link out 273","mode":"return","links":[],"x":445,"y":260,"wires":[]},{"id":"d09a9e75c1cb3fd9","type":"link call","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"call request","links":["2df1498ab5d28910"],"linkType":"static","timeout":"30","x":650,"y":760,"wires":[["06d4b90b7b3e2087"]]},{"id":"37572cdd83c4a88e","type":"link call","z":"5dfd7c4fa8812f8b","g":"1e6ac73d16d3e4fd","name":"call request","links":["2df1498ab5d28910"],"linkType":"static","timeout":"30","x":890,"y":440,"wires":[["fe38821d7708d05c"]]},{"id":"c3d6f0104c69996d","type":"catch","z":"5dfd7c4fa8812f8b","g":"75adeef4d28b4d5f","name":"All errors","scope":null,"uncaught":false,"x":160,"y":1080,"wires":[["d92a122a85e3b0cc"]]},{"id":"1fc4771ca6ce3334","type":"link out","z":"5dfd7c4fa8812f8b","g":"75adeef4d28b4d5f","name":"link out 300","mode":"link","links":["d3422b90f8530fb4"],"x":615,"y":1080,"wires":[]},{"id":"97d79dc47576aa9f","type":"debug","z":"5dfd7c4fa8812f8b","g":"75adeef4d28b4d5f","name":"debug NetAtmo","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":680,"y":1040,"wires":[]},{"id":"d92a122a85e3b0cc","type":"function","z":"5dfd7c4fa8812f8b","g":"75adeef4d28b4d5f","name":"Time + Fehlermeldung","func":"if (msg.payload.type === \"reset\"){\n node.status({ fill: \"green\", shape: \"dot\", text: \" \" });\n return null;\n}\n\nlet counter = context.get(\"counter\");\ncounter = counter + 1;\ncontext.set(\"counter\", counter);\n\nlet time = moment().tz(\"Europe/Berlin\").format(\"DD-MM-YYYY HH:mm:ss\");\n\nlet text = \"Fehlerzeitpunkt: \" + time + \" / \" +\n \"RPI 201\" + \" / \" +\n \"Flow: netatmo EGWZ sensor\" + \" / \" +\n \"Fehlermeldung: \" + msg.error.message + \" / \" +\n \"Fehler ID: \" + msg.error.source.id + \" / \" +\n \"Fehlertyp: \" + msg.error.source.type + \" / \" +\n \"Fehlernode: \" + msg.error.source.name + \" / \" +\n \"Fehlerzähler: \" + msg.error.source.count;\n \nnode.status({ fill: \"red\", shape: \"dot\", text: text + \" / \" + counter });\n\nreturn{payload:text};","outputs":1,"timeout":"","noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\nif (context.get(\"counter\") === undefined) {\n context.set(\"counter\", 0);\n}","finalize":"","libs":[{"var":"moment","module":"moment"},{"var":"momentTimezone","module":"moment-timezone"}],"x":420,"y":1080,"wires":[["1fc4771ca6ce3334"]]},{"id":"653ae61d5333b989","type":"link in","z":"5dfd7c4fa8812f8b","g":"75adeef4d28b4d5f","name":"debug","links":["198aa8893d75f395","e0b35f90dd344f8f","39c95ea1197778ad"],"x":505,"y":1040,"wires":[["97d79dc47576aa9f","1fc4771ca6ce3334"]]},{"id":"bb043a8f9a80d5ea","type":"inject","z":"5dfd7c4fa8812f8b","g":"75adeef4d28b4d5f","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"{\"type\":\"reset\"}","payloadType":"json","x":200,"y":1040,"wires":[["d92a122a85e3b0cc"]]},{"id":"39c95ea1197778ad","type":"link out","z":"5dfd7c4fa8812f8b","g":"37c406c4251df006","name":"to dedug","mode":"link","links":["653ae61d5333b989"],"x":1195,"y":920,"wires":[]},{"id":"99603ece.52e2a","type":"mqtt-broker","broker":"10.0.0.43","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":4,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.