Supergiovane / node-red-contrib-knx-ultimate

Control your KNX intallation via Node-Red! A bunch of KNX nodes, with integrated Philips HUE control and ETS group address importer.
https://youtu.be/egRbR_KwP9I
MIT License
147 stars 34 forks source link

Support parameters from env variables #365

Closed Alloc86 closed 3 months ago

Alloc86 commented 3 months ago

Hi Massimo,

another thing that working on my changes brought up. I know you personally don't really like subflows (at least you stated that a few years in the past :D ), but at least for me that would be tremendously helpful. No idea how complex supporting this would be though.

Is your feature request related to a problem? Please describe. Currently when I use subflows that take GA numbers as parameters I have to build "complex" structures in the subflow to get those GAs used by the KNX nodes inside. Example: image The inject nodes make sure the KNX nodes get their config set properly (using setConfig.setGroupAddress=env.get("GaStatusHelligkeit")). The switch on the output of the lower one makes sure it drops the KNX node output for the config message (i.e. filters messages with msg.event == "Update_NoWrite").

Describe the solution you'd like I would love if the KNX node would support using the env variables directly like most other Node RED nodes do. I.e. support selecting the kind of input on the "Group Addr." field in the node config like here: image So switch between string and env. var.

Describe alternatives you've considered Alternative currently is as shown above: Add two nodes before each KNX node to set up config, one after to filter the Update message it causes. Works, but it's quite a lot of additional stuff :D

Would be great if that could be added to v3, even though obviously I can work around if not :)

Supergiovane commented 3 months ago

Noted...

Do you know, there is a "Global Context Variable node" as well? https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/GlobalVariable Maybe it can help you.

Alloc86 commented 3 months ago

Yeah, using that for some other stuff. But it would not help here as I would have to poll that myself instead of getting notified for changes to a few specific GA :)

Supergiovane commented 3 months ago

Hi do you know, environment variables are read at node-red start as readonly? You can set the env variables at Flow level, for example, but then you cannot change it at runtime using, for example env.set("MyVar","MyValue"). Env.set doesn't' exists.

Alloc86 commented 3 months ago

Yes, but for use with subflows that's perfectly fine as subflows get their env variables set by the subflow instance configuration. That's how one can make subflows reusable other than feeding everything into them from the outside.

Supergiovane commented 3 months ago

Hi You'll be able to select env, global, flow beside string topic type. When you select "env", "global" or "flow", the datapoint will be automatically set, based on ETS file. It's ok for you?

Node-RED___Flow_4
Alloc86 commented 3 months ago

That looks really awesome!

Supergiovane commented 3 months ago

Hello,

Archivio.zip

if you feel comfortable, you can unzip this archive into your .node-red/node_modules/node-red-contrib-knx-ultimate/ folder.

Then, from a command line terminal, cd into .node-red/node_modules/node-red-contrib-knx-ultimate and type: npm install

Alloc86 commented 3 months ago

Thank you a lot! Actually right now I do not really have the spare time to do experiments (mother's birthday on sunday, but overall busy with work as we have a major release this weekend and bug fixing the following weeks most likely :D ), but I appreciate the option. Maybe I get around to it next weekend.

Curious, is that package based on the new "KNX engine"? Is that like a rewrite of the core code?

Supergiovane commented 3 months ago

Anyway, the new version 3.0.0 will be out today with your two issues addressed. The "new" KNX engine is a port from javascript to typescript. Is not actually "new". TypeScript should allow me to do less errors when adding new things. It should also (hope until the end of 2024) accomodate the KNX secure protocol.

Supergiovane commented 3 months ago

Hi v3.0.0-beta1 is out. I'm closing this issue. If you encounter problems, feel free to reopen it.

Alloc86 commented 3 months ago

Confirmed working so far, thank you!

Alloc86 commented 3 months ago

Actually ... looks like something got broken with the "old" way to set a nodes group address though. image Sending that to a device node like this (unchanged from before the update): image And the node does no longer output anything when there is a write on the GA, no matter if from the bus or from Node RED itself.

/EDIT: Also tried setting the 3-level GA empty in the node.

PS: It seems I can not reopen tickets :)

Supergiovane commented 3 months ago

I’m checking…

Alloc86 commented 3 months ago

Please don't hit me ... but it was my fault :D I forgot you told me to use setDPT = auto now :)

(I knew there was another change but couldn't find anything and could not remember what exactly it was ... was looking through other tickets now and found it in the setConfig ticket)

Supergiovane commented 3 months ago

Oh, good. I remember that it passed all unit tests. :-)

Supergiovane commented 3 months ago

It should be wrote in the node-red's help panel as well.

Alloc86 commented 3 months ago

Indeed, you just don't think you'd done something wrong when not changing anything but updating the third-party node :D Thanks again for these changes, it really helped clean up a lot of my shit! And many thanks for all your hard work on this node in general!