onokje / node-red-contrib-tesla

Node red nodes to control Tesla vehicles and devices
MIT License
20 stars 11 forks source link

Node-Red crash when retriving a Token is not possible #61

Open ange12lo opened 1 year ago

ange12lo commented 1 year ago

Hello everyone For the last few days the Tesla backend has been unreachable. It happened to me that node red crashed when the [node-red-contrib-tesla] was unable to retrieve a token.

`Welcome to Node-RED

25 Feb 06:53:22 - [info] Node-RED version: v3.0.2 25 Feb 06:53:22 - [info] Node.js version: v16.16.0 25 Feb 06:53:22 - [info] Linux 5.19.17-Unraid x64 LE 25 Feb 06:53:22 - [info] Loading palette nodes 25 Feb 06:53:23 - [info] Settings file : /data/settings.js 25 Feb 06:53:23 - [info] Context store : 'default' [module=memory] 25 Feb 06:53:23 - [info] User directory : /data 25 Feb 06:53:23 - [warn] Projects disabled : editorTheme.projects.enabled=false 25 Feb 06:53:23 - [info] Flows file : /data/flows.json 25 Feb 06:53:23 - [info] Server now running at http://127.0.0.1:1880/ 25 Feb 06:53:23 - [warn]


Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials file will not be recoverable, you will have to delete it and re-enter your credentials.

You should set your own key using the 'credentialSecret' option in your settings file. Node-RED will then re-encrypt your credentials file using your chosen key the next time you deploy a change.

25 Feb 06:53:23 - [info] Starting flows Tesla API: No token found. Getting new token now... Tesla API: doing api call to fetch new access token 25 Feb 06:53:23 - [info] Started flows 25 Feb 06:53:23 - [info] [mqtt-broker:Loxberry] Connected to broker: mqtt://192.168.99.99:1883 Tesla API: No token found. Getting new token now... Tesla API: doing api call to fetch new access token 25 Feb 06:53:32 - [red] Uncaught Exception: 25 Feb 06:53:32 - [error] Error at getNewTokenFromApi (/data/node_modules/node-red-contrib-tesla/src/tesla.js:35:19) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async /data/node_modules/node-red-contrib-tesla/src/tesla.js:282:31

Press ANY KEY to close this window `

EasternPA commented 1 year ago

I'm brand new to this node and ran into this issue on a fresh install. I deployed it in docker compose but couldn't use an internal volume. I mounted a local folder as the /data directory in Node RED and deployed the stack to populate the folder with real data. Then I shut down and deleted the stack and removed the image from docker. Then I edited settings.js in the mapped folder and uncommented the credentialSecret option near the top of the file (remove the two forward slashes '//').

Then I redeployed the stack from scratch. I added the Tesla node to the fresh NR install from the palette and was successfully able to connect to the car using the email and refresh token. You just need to uncomment what they tell you to, but docker makes it difficult to edit the file. You need to get a copy of the file, delete the docker image, edit the file, and redeploy using the edited file so NR deploys correctly. At least that process fixed it for me.