Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node Red crashes #21

Open
morpheus1984 opened this issue Feb 19, 2023 · 31 comments
Open

Node Red crashes #21

morpheus1984 opened this issue Feb 19, 2023 · 31 comments

Comments

@morpheus1984
Copy link

Hi, i am a Basic user with not that much know how. Since the change to OAuth2 i have problems with node red, it crashes several times a day. After restart everything works Fine again until the next exit.

are there some tips and tricks to avoid that?

Would be great if someone can help me.

greets Jan

Here the log:

Feb 19 09:52:00 homematic-raspi daemon.err node-red: 19 Feb 09:52:00 - [red] Uncaught Exception:
Feb 19 09:52:00 homematic-raspi daemon.err node-red: 19 Feb 09:52:00 - ReferenceError: callback is not defined
Feb 19 09:52:00 homematic-raspi daemon.err node-red: at ClientRequest. (/usr/local/addons/redmatic/var/node_modules/node-red-contrib-netatmo-dashboard/netatmo-dashboard.js:46:9)
Feb 19 09:52:00 homematic-raspi daemon.err node-red: at ClientRequest.emit (events.js:315:20)
Feb 19 09:52:00 homematic-raspi daemon.err node-red: at TLSSocket.socketErrorListener (_http_client.js:469:9)
Feb 19 09:52:00 homematic-raspi daemon.err node-red: at TLSSocket.emit (events.js:315:20)
Feb 19 09:52:00 homematic-raspi daemon.err node-red: at emitErrorNT (internal/streams/destroy.js:106:8)
Feb 19 09:52:00 homematic-raspi daemon.err node-red: at emitErrorCloseNT (internal/streams/destroy.js:74:3)
Feb 19 09:52:00 homematic-raspi daemon.err node-red: at processTicksAndRejections (internal/process/task_queues.js:80:21)
Feb 19 09:52:00 homematic-raspi daemon.err node-red: Node-RED exited with non-zero exit status 1

@tom666-debug
Copy link

I am facing the same issue with Node-RED is crashing/restarting caused by the netatmo-dashboard node.
This is what I have found in the Node-RED logfile:

24 Feb 12:32:27 - [red] Uncaught Exception:
24 Feb 12:32:27 - [error] TypeError: Cannot read properties of undefined (reading 'devices')
at NetatmoDashboard._inputCallback (/data/node_modules/node-red-contrib-netatmo-dashboard/netatmo-dashboard.js:96:19)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)

@morpheus1984
Copy link
Author

And what does that error mean? You have some idea?

@AleksCee
Copy link

AleksCee commented Mar 11, 2023

@tom666-debug
Line 96 is _(data.body.devices).each(function (station) {
So I think in your response is no data, perhaps Netatmo api was down or has no read permission to get the requested data in devices. Has your app the permission scope to read all?

@morpheus1984
In your case it’s at
.setTimeout(0)
.on('error', (error) => {
callback(error);
});

While fetching the access token. The code ends in the catch block an the callback Funktion is not exist. I think this is an bug. In the other error case the code will only wire a node.log() and not call callback Funktion.

@tom666-debug
Copy link

perhaps Netatmo api was down

This is really an issue :-(

Today my Node-RED Instance crashed 6 times in a row because of this.
Srsly, is there a chance to make this node a bit more robust?

@Mike4466
Copy link

Hello, I use this node because node-red-contrib-netatmo had not implemented the new authorization and I urgently needed another node. So I switched to this node only a few months ago.

My Node Red also crashes from time to time. It runs under RaspberryMatic.
Often during internet interruptions but probably otherwise as well.
My problem is that I have to start Node Red manually afterwards, because it crashes so many times in a row.

I have now set that Node Red does not give up after 3 times reboot but endlessly tries to start Node Red after crashes.
Whether this is smart, I do not know, but if the home automation does not work all day, only because the Netatmo Node crashd when authorizing, is worse for me.

If anyone can give me a suggestion on where I can change something to work around the problem, I would be grateful.

Greetings, Mike

Here the relevant part of the log:
Aug 25 08:14:22 homematic-ccu2 daemon.err node-red: 25 Aug 08:14:22 - [red] Uncaught Exception:
Aug 25 08:14:22 homematic-ccu2 daemon.err node-red: 25 Aug 08:14:22 - ReferenceError: callback is not defined
Aug 25 08:14:22 homematic-ccu2 daemon.err node-red: at ClientRequest. (/usr/local/addons/redmatic/var/node_modules/node-red-contrib-netatmo-dashboard/netatmo-dashboard.js:46:9)
Aug 25 08:14:22 homematic-ccu2 daemon.err node-red: at ClientRequest.emit (events.js:315:20)
Aug 25 08:14:22 homematic-ccu2 daemon.err node-red: at TLSSocket.socketErrorListener (_http_client.js:469:9)
Aug 25 08:14:22 homematic-ccu2 daemon.err node-red: at TLSSocket.emit (events.js:315:20)
Aug 25 08:14:22 homematic-ccu2 daemon.err node-red: at emitErrorNT (internal/streams/destroy.js:106:8)
Aug 25 08:14:22 homematic-ccu2 daemon.err node-red: at emitErrorCloseNT (internal/streams/destroy.js:74:3)
Aug 25 08:14:22 homematic-ccu2 daemon.err node-red: at processTicksAndRejections (internal/process/task_queues.js:80:21)
Aug 25 08:14:22 homematic-ccu2 daemon.err node-red: Node-RED exited with non-zero exit status 1
Aug 25 08:14:22 homematic-ccu2 daemon.err redmatic: Maximum Node-RED restarts exceeded

@morpheus1984
Copy link
Author

Hi Mike, i also found out that this Happens when my Internet Connection gets lost.
I did the same, ebdless restarts After crash.
But i think its not normal that complete Node red crashes if one node cant work fine. All my other nodes dont really care if Connection fails for some minutes.

@tom666-debug
Copy link

Of course, it's not the nodes fault that there are outages from time to time on Netatmo-side (or if the connection to the internet is down). But it cannot be that for such a reason complete NoreRED is crashing. This node needs better exception handling urgently.

@S474N
Copy link

S474N commented Aug 29, 2023

Also have every day crash of NodeRED:

2023-07-24T14:42:05.034968916Z 24 Jul 16:42:05 - [red] Uncaught Exception:
2023-07-24T14:42:05.035452838Z 24 Jul 16:42:05 - [error] ReferenceError: callback is not defined
2023-07-24T14:42:05.035506670Z     at ClientRequest.<anonymous> (/data/node_modules/node-red-contrib-netatmo-dashboard/netatmo-dashboard.js:46:9)
2023-07-24T14:42:05.035523744Z     at ClientRequest.emit (events.js:400:28)
2023-07-24T14:42:05.035538059Z     at TLSSocket.socketErrorListener (_http_client.js:475:9)
2023-07-24T14:42:05.035551892Z     at TLSSocket.emit (events.js:400:28)
2023-07-24T14:42:05.035574948Z     at emitErrorNT (internal/streams/destroy.js:106:8)
2023-07-24T14:42:05.035589985Z     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
2023-07-24T14:42:05.035603892Z     at processTicksAndRejections (internal/process/task_queues.js:82:21)
2023-07-24T14:42:10.661695409Z 24 Jul 16:42:10 - [info] 


2023-07-24T14:44:05.069983517Z 24 Jul 16:44:05 - [red] Uncaught Exception:
2023-07-24T14:44:05.070552734Z 24 Jul 16:44:05 - [error] ReferenceError: callback is not defined
2023-07-24T14:44:05.070608826Z     at ClientRequest.<anonymous> (/data/node_modules/node-red-contrib-netatmo-dashboard/netatmo-dashboard.js:46:9)
2023-07-24T14:44:05.070625419Z     at ClientRequest.emit (events.js:400:28)
2023-07-24T14:44:05.070639752Z     at TLSSocket.socketErrorListener (_http_client.js:475:9)
2023-07-24T14:44:05.070654270Z     at TLSSocket.emit (events.js:400:28)
2023-07-24T14:44:05.070667937Z     at emitErrorNT (internal/streams/destroy.js:106:8)
2023-07-24T14:44:05.070681529Z     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
2023-07-24T14:44:05.070695233Z     at processTicksAndRejections (internal/process/task_queues.js:82:21)
2023-07-24T14:44:07.529093361Z 24 Jul 16:44:07 - [info] 


2023-07-25T09:00:09.540446829Z 25 Jul 11:00:09 - [red] Uncaught Exception:
2023-07-25T09:00:09.541065305Z 25 Jul 11:00:09 - [error] ReferenceError: callback is not defined
2023-07-25T09:00:09.541131175Z     at ClientRequest.<anonymous> (/data/node_modules/node-red-contrib-netatmo-dashboard/netatmo-dashboard.js:46:9)
2023-07-25T09:00:09.541148045Z     at ClientRequest.emit (events.js:400:28)
2023-07-25T09:00:09.541162563Z     at TLSSocket.socketErrorListener (_http_client.js:475:9)
2023-07-25T09:00:09.541177193Z     at TLSSocket.emit (events.js:400:28)
2023-07-25T09:00:09.541190989Z     at emitErrorNT (internal/streams/destroy.js:106:8)
2023-07-25T09:00:09.541204896Z     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
2023-07-25T09:00:09.541218674Z     at processTicksAndRejec

2023-07-28T03:26:10.883676632Z 28 Jul 05:26:10 - [red] Uncaught Exception:
2023-07-28T03:26:10.884243071Z 28 Jul 05:26:10 - [error] ReferenceError: callback is not defined
2023-07-28T03:26:10.884311367Z     at ClientRequest.<anonymous> (/data/node_modules/node-red-contrib-netatmo-dashboard/netatmo-dashboard.js:46:9)
2023-07-28T03:26:10.884329163Z     at ClientRequest.emit (events.js:400:28)
2023-07-28T03:26:10.884343514Z     at TLSSocket.socketErrorListener (_http_client.js:475:9)
2023-07-28T03:26:10.884357811Z     at TLSSocket.emit (events.js:400:28)
2023-07-28T03:26:10.884371496Z     at emitErrorNT (internal/streams/destroy.js:106:8)
2023-07-28T03:26:10.884385051Z     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
2023-07-28T03:26:10.884398625Z     at processTicksAndRejections (internal/process/task_queues.js:82:21)
2023-07-28T03:26:13.835490094Z 28 Jul 05:26:13 - [info] 



2023-08-28T04:54:09.598840260Z 28 Aug 06:54:09 - [red] Uncaught Exception:
2023-08-28T04:54:09.599820362Z 28 Aug 06:54:09 - [error] ReferenceError: callback is not defined
2023-08-28T04:54:09.599892361Z     at ClientRequest.<anonymous> (/data/node_modules/node-red-contrib-netatmo-dashboard/netatmo-dashboard.js:46:9)
2023-08-28T04:54:09.599966027Z     at ClientRequest.emit (events.js:400:28)
2023-08-28T04:54:09.599981971Z     at TLSSocket.socketErrorListener (_http_client.js:475:9)
2023-08-28T04:54:09.599995879Z     at TLSSocket.emit (events.js:400:28)
2023-08-28T04:54:09.600009341Z     at emitErrorNT (internal/streams/destroy.js:106:8)
2023-08-28T04:54:09.600022675Z     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
2023-08-28T04:54:09.600036286Z     at processTicksAndRejections (internal/process/task_queues.js:82:21)
2023-08-28T04:54:12.518238804Z 28 Aug 06:54:12 - [info] 

@S474N
Copy link

S474N commented Sep 8, 2023

It's really unbearable, there are very frequent restarts of Nodered. Would it be possible to fix it somehow?!

This is just for today:
image

@tom666-debug
Copy link

Seems owner of this project is not able or willing to fix this (improved exception handling). Pretty sad ...

@hflatoey
Copy link

hflatoey commented Nov 7, 2023

Same problem here, restarts about once every day...

7 Nov 13:19:03 - [red] Uncaught Exception:
7 Nov 13:19:03 - [error] ReferenceError: callback is not defined
at ClientRequest. (/data/node_modules/node-red-contrib-netatmo-dashboard/netatmo-dashboard.js:46:9)
at ClientRequest.emit (node:events:513:28)
at TLSSocket.socketErrorListener (node:_http_client:494:9)
at TLSSocket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
7 Nov 13:19:07 - [info]

Welcome to Node-RED
7 Nov 13:19:07 - [info] Node-RED version: v3.1.0
7 Nov 13:19:07 - [info] Node.js version: v16.20.2
7 Nov 13:19:07 - [info] Linux 6.1.49-Unraid x64 LE

@matz33
Copy link

matz33 commented Nov 23, 2023

Hi,

Same problem here. This module makes my Nodred crash several times a day. And unfortunately the guy behind this module is not willing to fix anything here. It is pretty simple to get rid of this module with a simple http request. Here is what I'm using and I have the exact same info, using http request :
image

The URL is : https://api.netatmo.com/api/getstationsdata
The token is the one returned by netatmo when you authenticate to the site like explained in the doc of this module

Et voilà ! It gives me exactly the same json as the "detailed" section of the json returned by this buggy module.


You can get more URL exemples from API Netatmo here : https://cbornet.github.io/netatmo-swagger-decl/swagger-ui/
To use this page :

  • for exemple click on "Show/Hide" in front of "Station : Weather station specific methods"
  • click on "GET / getstationdata"
  • you will see a red exclamation mark : click on it. In the form, check "read_station" then "Authorize"
  • this will bring you to Netatmo authentication page, enter your credentials. Click accept
  • then the red exclamation mark is now a blue "i"
  • you can then click on "Try it out" below. This will return the data. In "Curl" part just below the button "Try it out" you have the URL to enter in the http request node.
  • For exemple :
    curl -X GET --header 'Accept: application/json' 'https://api.netatmo.net/api/getstationsdata?access_token=5....
    The url you want to put in the request http node is here : https://api.netatmo.net/api/getstationsdata

@tom666-debug
Copy link

@matz33
Works like charme ... Thank you so much for sharing this with us!
Finally I can get rid of the piece of trash module

@ceLeXo114
Copy link

Was affected by the same errors as described above.
The workaround from matz33 seems to be working for me so far.
I just had to adjust the path (leave out .detailed) when reading out the individual values.

Thank you @matz33!

@morpheus1984
Copy link
Author

Hi guys, could maybe anyone help me with the token topic. I tried it, but I think I did not get the topic.
I see the access and refresh token on the Netatmo api page, but I expires quit fast. What do I exactly need to do to get the right key? could you maybe help me to get it running?Thanks a lot.

@tom666-debug
Copy link

Hi guys, could maybe anyone help me with the token topic. I tried it, but I think I did not get the topic. I see the access and refresh token on the Netatmo api page, but I expires quit fast. What do I exactly need to do to get the right key? could you maybe help me to get it running?Thanks a lot.

I am facing the same issue. Regarding to the NetAtmo description, the token must be refreshed every 3 hours. Therefore the "refresh token" must be used.


Refreshing a token
When you request a token (via grant type credentials or authorization code) you retrieve as well the validity timelapse and a refresh token. Once your token has expired, you'll have to request a new one using the grant_type refresh_token.

Endpoint: https://api.netatmo.com/oauth2/token
Method: POST


Any ideas how this could be achieved?

@matz33
Copy link

matz33 commented Nov 24, 2023

You are right : the token needs to be refreshed. You will find at the end of this post my flow to get the token refreshed. I've just finished it, and the token works 3 hours, so I will know in 3 hours if it refreshes correctly :)

Here is how it works :

  • Enter your token and refresh token + client id and client secrect in the node "Set Netatmo Creds & Tokens"
  • Trigger the inject node "Set first info"
  • Then, the inject node "Start" can be triggered either automatically after a deploy like I configured it (prefered method), or manually if needed
  • It will get the token, refresh token, and will refresh them after the expiration (returned in the payload by Netatmo) - 5 minutes
  • If error in getting the token it will retry after 1 hour. You can add here any kind of alert (email, etc) after node "Delay 1 hour on error" to alert you that there is an error and token was not returned (time out etc)
  • The node "Next refresh in..." displays the next time the refresh will occur
  • The token you need to use in the http request above is in Global "NetatmoAccessToken"
  • This is what I do after the node "Get Netatmo Data" : it gets the data needed

Hope that helps

[{"id":"48c9ba7a4d6a5359","type":"http request","z":"dab956b5.a43dd8","name":"Send refresh request","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://api.netatmo.com/oauth2/token","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"other","valueValue":"application/x-www-form-urlencoded"}],"x":920,"y":1260,"wires":[["1d54981a5bd62dc8"]]},{"id":"493b859e5318d28d","type":"inject","z":"dab956b5.a43dd8","name":"Start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":150,"y":1220,"wires":[["fef4ac6631a48776"]]},{"id":"fef4ac6631a48776","type":"change","z":"dab956b5.a43dd8","name":"Set param request refresh","rules":[{"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"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":1260,"wires":[["48c9ba7a4d6a5359"]]},{"id":"65f4b6541bc97008","type":"change","z":"dab956b5.a43dd8","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":1340,"y":1200,"wires":[["55d78fcc3650ef5c","97c519fc69b9b6e9"]]},{"id":"371e46c1b4744f71","type":"change","z":"dab956b5.a43dd8","name":"Set Netatmo Creds & Tokens","rules":[{"t":"set","p":"NetatmoClientId","pt":"global","to":"Your_client_id","tot":"str"},{"t":"set","p":"NetatmoClientSecret","pt":"global","to":"Your_client_secret","tot":"str"},{"t":"set","p":"NetatmoAccessToken","pt":"global","to":"Your_first_token","tot":"str"},{"t":"set","p":"NetatmoRefreshToken","pt":"global","to":"Your_first_refres_token","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":1180,"wires":[[]]},{"id":"acb161c2964a5538","type":"inject","z":"dab956b5.a43dd8","name":"Set first info","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":1180,"wires":[["371e46c1b4744f71"]]},{"id":"5dd80c83a73ef692","type":"inject","z":"dab956b5.a43dd8","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":150,"y":1300,"wires":[["55d78fcc3650ef5c","97c519fc69b9b6e9","586be2751752f395"]]},{"id":"1d54981a5bd62dc8","type":"switch","z":"dab956b5.a43dd8","name":"All ok ?","property":"payload","propertyType":"msg","rules":[{"t":"hask","v":"access_token","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1120,"y":1260,"wires":[["65f4b6541bc97008"],["ffd6c9bccc7f0c84"]],"outputLabels":["Response OK","Error"]},{"id":"ffd6c9bccc7f0c84","type":"change","z":"dab956b5.a43dd8","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":1340,"y":1320,"wires":[["55d78fcc3650ef5c","97c519fc69b9b6e9"]]},{"id":"55d78fcc3650ef5c","type":"delay","z":"dab956b5.a43dd8","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":460,"y":1260,"wires":[["fef4ac6631a48776"]]},{"id":"97c519fc69b9b6e9","type":"delay","z":"dab956b5.a43dd8","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":460,"y":1320,"wires":[["586be2751752f395"]]},{"id":"586be2751752f395","type":"function","z":"dab956b5.a43dd8","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":480,"y":1380,"wires":[["97c519fc69b9b6e9"],[]]},{"id":"944f8def659f9d52","type":"change","z":"dab956b5.a43dd8","name":"","rules":[{"t":"set","p":"token","pt":"msg","to":"\"Bearer \" & $globalContext(\"NetatmoAccessToken\")\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":1460,"wires":[["b96f28348953dfca"]]},{"id":"b96f28348953dfca","type":"http request","z":"dab956b5.a43dd8","name":"Netatmo Https","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.netatmo.com/api/getstationsdata","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Authorization","valueType":"msg","valueValue":"token"}],"x":680,"y":1460,"wires":[["7df73f6e51fbc4a5"]]},{"id":"7f8ab2a7eb362ac8","type":"inject","z":"dab956b5.a43dd8","name":"Get Netatmo Data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":1460,"wires":[["944f8def659f9d52"]]},{"id":"7df73f6e51fbc4a5","type":"debug","z":"dab956b5.a43dd8","name":"Netatmo Data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":900,"y":1460,"wires":[]}]

@matz33
Copy link

matz33 commented Nov 24, 2023

I created a flow here so eveybody can use it : https://flows.nodered.org/flow/843165d0046cac534864b65e633801a5

@tom666-debug
Copy link

@matz33
Just in case of a Node-RED restart, would it be an option to store/read the tokens values to/from a file instead of setting global variables?

@matz33
Copy link

matz33 commented Nov 24, 2023

Good idea, I will try to work on this

@matz33
Copy link

matz33 commented Nov 24, 2023

BTW after several hours and refresh, it seems to work well.

@tom666-debug
Copy link

it seems to work well.

Confirmed, also on my end its running stable since yesterday afternoon.
I have noticed that the token and the refreshtoken as well didnt changed - My expectation was that every time I send a "refresh request" I will get a new token ... strange.

@matz33
Copy link

matz33 commented Nov 25, 2023

Same here. Maybe they just want us to call the authent url regularly with both token and that is the refreshing the tokens themselves, without changing them

@tom666-debug
Copy link

tom666-debug commented Nov 25, 2023

just came across this:


https://www.oauth.com/oauth2-servers/access-tokens/refreshing-access-tokens/

If everything checks out, the service can generate an access token and respond. The server may issue a new refresh token in the response, but if the response does not include a new refresh token, the client assumes the existing refresh token will still be valid.


@matz33
Copy link

matz33 commented Nov 26, 2023

@matz33 Just in case of a Node-RED restart, would it be an option to store/read the tokens values to/from a file instead of setting global variables?

For this, I'm using the option to save context data to the file-system described here : https://nodered.org/docs/user-guide/context#saving-context-data-to-the-file-system. After a restart, eveyrhing is restored in global variables

@morpheus1984
Copy link
Author

Hi Matz, I tried it, but something won't work. Maybe you can help me?
27.11.2023, 17:26:45node: Netatmo Data
msg : Object
object
_msgid: "f412923e.50d37"
payload: object
error: object
code: 1
message: "Access token is missing"
topic: ""
token: "Bearer XXXXXXXXXXX"
statusCode: 400
headers: object
server: "nginx"
date: "Mon, 27 Nov 2023 16:26:45 GMT"
content-type: "application/json; charset=utf-8"
transfer-encoding: "chunked"
connection: "close"
cache-control: "no-cache, must-revalidate"
expires: "0"
x-xss-protection: "1; mode=block"
access-control-allow-origin: "*"
strict-transport-security: "max-age=31536000; includeSubDomains"
x-powered-by: "Netatmo"
x-node-red-request-node: "a23e33dc"
responseUrl: "https://api.netatmo.com/api/getstationsdata"
redirectList: array[0]

@tom666-debug
Copy link

tom666-debug commented Nov 29, 2023

@morpheus1984
Have you tried to generate a new pair of token/refreshtoken on the Netatmo Website (https://dev.netatmo.com)?
I was also forced to do so because my "old" tokens didnt work anymore.

@morpheus1984
Copy link
Author

Hi, maybe I am not known enough, just refreshed the complete data on the NetAtmo sie, but I get the same response.

image

image

@djiwondee
Copy link

Coming back to the initial post from @morpheus1984. I have configured a complete new config with this node-red-contrib and it works quite well. But the incomprehensible and inexplicable crashes still happens some times

2024-02-18T20:11:16.469317+01:00 {{hostname}} Node-RED[2085783]: 18 Feb 20:11:16 - [red] Uncaught Exception:
2024-02-18T20:11:16.469942+01:00 {{hostname}} Node-RED[2085783]: 18 Feb 20:11:16 - [error] ReferenceError: callback is not defined
2024-02-18T20:11:16.470184+01:00 {{hostname}} Node-RED[2085783]:     at ClientRequest.<anonymous> (/home/pi/.node-red/node_modules/node-red-contrib-netatmo-dashboard/netatmo-dashboard.js:46:9)
2024-02-18T20:11:16.470353+01:00 {{hostname}} Node-RED[2085783]:     at ClientRequest.emit (node:events:518:28)
2024-02-18T20:11:16.470519+01:00 {{hostname}} Node-RED[2085783]:     at TLSSocket.socketErrorListener (node:_http_client:495:9)
2024-02-18T20:11:16.470681+01:00 {{hostname}} Node-RED[2085783]:     at TLSSocket.emit (node:events:518:28)
2024-02-18T20:11:16.470885+01:00 {{hostname}} Node-RED[2085783]:     at emitErrorNT (node:internal/streams/destroy:169:8)
2024-02-18T20:11:16.471046+01:00 {{hostname}} Node-RED[2085783]:     at emitErrorCloseNT (node:internal/streams/destroy:128:3)
2024-02-18T20:11:16.471236+01:00 {{hostname}} Node-RED[2085783]:     at processTicksAndRejections (node:internal/process/task_queues:82:21)
2024-02-18T20:11:16.616556+01:00 {{hostname}} systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
2024-02-18T20:11:16.617069+01:00 {{hostname}} systemd[1]: nodered.service: Failed with result 'exit-code'.
2024-02-18T20:11:16.617429+01:00 {{hostname}} systemd[1]: nodered.service: Consumed 6h 16min 51.144s CPU time.
2024-02-18T20:11:36.857489+01:00 {{hostname}} systemd[1]: nodered.service: Scheduled restart job, restart counter is at 1.
2024-02-18T20:11:36.858498+01:00 {{hostname}} systemd[1]: Stopped nodered.service - Node-RED graphical event wiring tool.

@matz33
Copy link

matz33 commented Feb 19, 2024

I think you should definitely abandon this shitty node and use my exemple here https://gist.github.com/matz33/843165d0046cac534864b65e633801a5. Several users succeeded in using it. Have you tried to find a solution in getting the access token on netatmo website and add them in my flow ?
On my side, it is working without any errors since several months

@djiwondee
Copy link

@matz33 Thanks for pointing me to the gist. Have it implemented just right and it is working as expected. Haven't had so much to change related to the slightly different payload keys.

Have you tried to find a solution in getting the access token on netatmo website and add them in my flow ?

Yes, I did. There is an app management available at https://dev.netatmo.com/apps/

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants