bewee / node-red-contrib-webthingsio

https://www.npmjs.com/package/node-red-contrib-webthingsio
Mozilla Public License 2.0
1 stars 2 forks source link

Add option to send current value on inject node creation #14

Open freaktechnik opened 3 years ago

freaktechnik commented 3 years ago

In some cases when using an inject node you want the initial value to be sent when the flow is initialized, so the initial state is set. Currently to do so, you have to use the standard inject node with it set to fire after startup and chain it to a get for the same thing as the inject is adding. Of course this can't work for pure events, but anything with a state this should be possible.

bewee commented 3 years ago

Good idea!

What do you think, should this rather be a feature of the "get" node or of the "inject" node?

To add my two cents: Implementing this on the inject node may be a little more tricky than just adding a checkbox "execute on flow initializaton" (or smiliar) to the get node. However, implementing it on the inject node would also allow for behaviour like "inject connected state (of thing) on flow initialization"

freaktechnik commented 3 years ago

The reason it's not as interesting on the get node is that I generally need some inject to trigger the get in the first place, while the injects tend to start a flow. If I want state in my flow to be initialized the inject nodes would thus have to emit something when the flow is loaded.

bewee commented 3 years ago

Trying to clarify: What I meant was making it possible to use the "thing get" node like a "thing inject" node, just for getting properties on flow initialization only. One could then enable this behaviour on the get node through a checkbox or something. Afaik Node-RED allows a node with an input channel to start a flow by itself anyway (if one decides to implement it that way). Then you would no longer need an additional node to inject into the get node, but rather (if such a checkbox is checked) the get node would inject on its own. Hope that makes it a little clearer😅

That said, I do am just as well in favour of implementing this feature on the inject node (Because it could be more general - e.g. connect states. And because it is probably more visually pleasing & intuitive than having a node with an input channel that starts a flow without any other node injecting into it). Just wanted to bring up the other option because I thought it may be interesting for its (I guess) comparable simple implementation :)

Or maybe I have somewhat missunderstood you. If you feel like that, it would be great if you could try to describe your issue a little more in detail🙈 :)