zachowj / node-red-contrib-home-assistant-websocket

Node-RED integration with Home Assistant
https://zachowj.github.io/node-red-contrib-home-assistant-websocket/
MIT License
489 stars 89 forks source link

Deprecated API warning: Calls to RED.util.evaluateJSONataExpression must include a callback #898

Closed htmltiger closed 11 months ago

htmltiger commented 1 year ago

Describe the bug

Just upgraded to node red 3.1.0-beta.2 but greeted with the following

[warn] Deprecated API warning: Calls to RED.util.evaluateJSONataExpression must include a callback. 
This will not be optional in Node-RED 4.0. Please identify the node from the following stack 
and check for an update on npm. If none is available, please notify the node author.
[warn] Error
at Object.evaluateJSONataExpression (/home/pi/.node-red/node_modules/@node-red/util/lib/util.js:777:18)
at JSONataService.evaluate (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/dist/common/services/JSONataService.js:58:39)
at TypedInputService.getValue (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/dist/common/services/TypedInputService.js:58:85)
at EventsAll.getTypedInputValue (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/dist/nodes/BaseNode.js:134:39)
at /home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/dist/nodes/BaseNode.js:138:32
at Array.forEach (<anonymous>)
at EventsAll.setCustomOutputs (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/dist/nodes/BaseNode.js:137:20)
at EventsAll.onHaEventsAll (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/dist/nodes/events-all/controller.js:57:18)
at EventEmitter.<anonymous> (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/dist/nodes/EventsNode.js:39:17)
at EventEmitter.emit (node:events:525:35)
at Websocket._Websocket_emitEvent (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/dist/homeAssistant/Websocket.js:394:67)
at Websocket.onClientEvents (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/dist/homeAssistant/Websocket.js:238:87)
at Object.callback (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/dist/homeAssistant/Websocket.js:143:65)
at /home/pi/.node-red/node_modules/home-assistant-js-websocket/dist/haws.cjs:236:34
at Array.forEach (<anonymous>)
at Connection._handleMessage (/home/pi/.node-red/node_modules/home-assistant-js-websocket/dist/haws.cjs:231:26)
at callListener (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onMessage (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/event-target.js:209:9)
at WebSocket.emit (node:events:513:28)
at Receiver.receiverOnMessage (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/websocket.js:1184:20)
at Receiver.emit (node:events:513:28)
at Receiver.dataMessage (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/receiver.js:541:14)

To Reproduce

upgraded node-red by npm install node-red@next

Expected behavior

No response

Screenshots

No response

Example Flow

No response

This package's version (not the Home Assistant add-on version)

0.49

Is Node-RED running in Docker?

No

Node-RED version

3.1.0-beta.2

Node.js version

18.15.0

Additional context

No response

meironke commented 1 year ago

@meironke you have, inside of container!

docker exec -it nodered bash

Works like a charm! Thank you!

I thought it would be in the 'data' folder, but it is not! Here's a detailed "how to".

  1. docker exec -it nodered bash #if your container is called "nodered" and not "nodered_prod_orWhatEver"
  2. nano node_modules/@node-red/util/lib/util.js
  3. CTRL-Q and seach for "Deprecated API"
  4. Comment out the lines with //

Should look like this then (without the colors). 2023-09-18 11_06_55-● util js - ingo  SSH_ nuc  - Visual Studio Code

mraita commented 1 year ago

Hi, maybe i found a workaround for users of the NR-Addon. Put the following line in the config page of the Addon in the section init_commands and restart the addon.

sed -i "772,775d" /opt/node_modules/@node-red/util/lib/util.js

( added missing /opt/ thx @kevinschmidt86 )

Problem temporary solved. Please read the Thread !!!

jagradang commented 1 year ago

Hi, maybe i found a workaround for users of the NR-Addon. Put the following line in the config page of the Addon in the section init_commands and restart the addon. sed -i "772,775d" /opt/node_modules/@node-red/util/lib/util.js ( added missing /opt/ thx @kevinschmidt86 )

Problem temporary solved. Please read the Thread !!!

A temporary hack is not a FIX - I asked when will this be "FIXED". no reason to downvote the post?

mraita commented 1 year ago

Hi, maybe i found a workaround for users of the NR-Addon. Put the following line in the config page of the Addon in the section init_commands and restart the addon. sed -i "772,775d" /opt/node_modules/@node-red/util/lib/util.js ( added missing /opt/ thx @kevinschmidt86 )

Problem temporary solved. Please read the Thread !!!

Maybe you need to read my reply before meaninglessly down voting my post - I use node red inside Home assistant so i cant use this "work around".

I use it also in HA and it work for me ant the other Addon Users. Edit: I mean that whas a Temporary method not a fix. Sorry for that but we all here wait for a better solution, no need to spam the e-mail inbox for ewery useless comment.

Mithrox commented 1 year ago

A temporary hack is not a FIX - I asked when will this be "FIXED". no reason to downvote the post?

The issue is a warning of something that will happen in the next major version of NR, at that point the nodes/calls will need to be done differently. The temporary fix is solving THIS problem, as the thread is about. It removes all those spamming warnings in your debug window. The thread has the fix both for those running NR in a container, and for those of us who run it as an addon in HA. So the "problem" is solved by this thread, but there should be changes done before NR 4.0 comes out.

bernardesarthur commented 1 year ago

Guys, please see this: https://github.com/zachowj/node-red-contrib-home-assistant-websocket/pull/1063

ab5000 commented 11 months ago

Please fix

ab5000 commented 11 months ago

Hi, maybe i found a workaround for users of the NR-Addon. Put the following line in the config page of the Addon in the section init_commands and restart the addon. sed -i "772,775d" node_modules/@node-red/util/lib/util.js

Worked for me, except I had to add "/opt/" the string, resulting in the following: "sed -i "772,775d" /opt/node_modules/@node-red/util/lib/util.js"

Worked for me! Thank you so much!

Edit: In case you want to know what this does, rather than blindly run it (like I did 🤷 ), it deletes the code lines that are logging the Warn message from the javascript library file. It does not change any code behavior.

It also means you may need to reapply this delete if you receive further updates that overwrite this file (and they still haven't fixed this)

edd189 commented 11 months ago

Adding another vote to fix this. The debug window is useless with these warnings constantly filling it up.

henriklund commented 11 months ago

Adding another vote to fix this. The debug window is useless with these warnings constantly filling it up.

Please check 1063 (already mentioned last week - see a few posts ago). This is now just awaiting the normal release pipeline.

Ferrari2 commented 11 months ago

It seems the Node Red guys are out of control in this case - and that is really really bad for the node red society.

I unfortunately think, I now have to change away from the ever changing node red to the build in action controls of Home Assistant.

Mithrox commented 11 months ago

It seems the Node Red guys are out of control in this case - and that is really really bad for the node red society.

I unfortunately think, I now have to change away from the ever changing node red to the build in action controls of Home Assistant.

First off, I don't really know what you're referring to when you say "out of control", I've used Node Red a lot the last 2 years, and this is the only issue I have ever had. Second, you can just implement the fix over, it takes 10 seconds and then you restart the add-on, problem solved. When it's changed in NR add-on/nodes you can just remove the line again from your configuration. I think you're making this into a much bigger thing than it has to, but if you want to move all your automations over to native Home Assistant, go ahead. You either have very simple automations, or you have way too much time on your hands. Node Red wins hands down any day of the week in simplicity and flexibility.

zachowj commented 11 months ago

This issue has been fixed and will be in the next release.

This issue never stopped the Home Assistant nodes from working correctly, it was just an annoyance. Solutions to remove this annoyance have been posted above in this issue.

zachowj commented 11 months ago

Beta released https://github.com/zachowj/node-red-contrib-home-assistant-websocket/releases/tag/v0.57.0-beta.1