chameleonbr / node-red-contrib-redis

Node RED client for Redis with pub/sub, list, lua scripting and other commands support.
MIT License
46 stars 40 forks source link

Error with JSONata config #67

Open PJ-Schulz opened 2 months ago

PJ-Schulz commented 2 months ago

I run NodeRed in Kubernetes and want to pass some environment variables like host, username, password and so on as environment variables to the container.

But when I use at least a small variant only with the host address i get an error.

9 Jul 13:29:10 - [error] [redis-config:Redis] Missing options in the redis config - Are you upgrading from old version?
9 Jul 13:29:10 - [error] [redis-config:Redis] Missing options in the redis config - Are you upgrading from old version?
9 Jul 13:29:10 - [error] [redis-in:02924f467d4f2799] TypeError: Cannot read properties of undefined (reading 'on')

This is the configuration of my redis instance:

{
  "host": $env('redis_host')
}

When I press the inject node which is configured with JSONata: $env('redis_host') I get the correct parameter I have set. So the environment variable will be passed correctly to the container and NodeRed can read it.

What must I change in my configuration to make it work?

PS: I am using this commit: 34103964acc7159388a1ca1c94d76894b272bab3 because I use NodeRed 4

My flow:

grafik

[{"id":"ec1fd2a9a2f3cff8","type":"tab","label":"Basic Flow","disabled":false,"info":"","env":[]},{"id":"e3b3d83b76ec9607","type":"redis-instance","z":"ec1fd2a9a2f3cff8","server":"73589485eb3882eb","name":"","topic":"redis","location":"global","x":190,"y":80,"wires":[]},{"id":"02924f467d4f2799","type":"redis-in","z":"ec1fd2a9a2f3cff8","server":"73589485eb3882eb","command":"subscribe","name":"","topic":"my-channel","obj":false,"timeout":"0","x":210,"y":140,"wires":[["db46548d837e7355"]]},{"id":"db46548d837e7355","type":"debug","z":"ec1fd2a9a2f3cff8","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":460,"y":140,"wires":[]},{"id":"153e64a7f777a1ed","type":"inject","z":"ec1fd2a9a2f3cff8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"$env('redis_host')","payloadType":"jsonata","x":190,"y":200,"wires":[["705347879b008e5c"]]},{"id":"705347879b008e5c","type":"debug","z":"ec1fd2a9a2f3cff8","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":460,"y":200,"wires":[]},{"id":"73589485eb3882eb","type":"redis-config","name":"Redis","options":"{\t  \"host\": $env('redis_host')\t}","cluster":false,"optionsType":"jsonata"}]