Multiple nodes or not?

Hi all,

this is a general Node-Red question really, looking for some guidance in tidy planning I guess.

Is it better i.e. more efficient/less cumbersome/easier to de-bug etc to use one events:state node multiple times throughout a series of flows or have just one copy of it and use links?

I’m really just trying to figure out a tidy way to ensure my ever-growing NR setup is as easy as possible to de-bug or make changes to etc.

Currently I might have say a motion detector state-change node in one flow, but also need that input in another flow - how best to do this??

It was easy when I just had a beginning setup but now I have many flows, broken down into lights for each room, motion, heating control, and many more. It’s growing and I want to keep control of it. Is there a guide to sensible design maybe??

Thanks in advance

Well the device node is not really something you should use. There is a problem with device id’s in that they cannot be replicated. Meaning if a light bulb burns out and you need to change it, you would also need to update the node.

This is explained in detail here. Use event state or trigger nodes with entity id’s. If I trigger multiple actions from a single entity, I will have multiple event state/trigger nodes.

An example, my camera motion can trigger both lighting and a notification. All my lighting is on a single page while all my notifications are on another.

Thanks,

my first post was incorrect in my terminology - i do not use “device” nodes, I should have said “Events:state” - I’ll correct my post if I can.

Using your example, I would use multiple Events:state nodes as and where needed.

Next question is say I have a flow which waits for an events:state input, makes some checks etc and sends an output service-call to a device, maybe a smart bulb. Then in another flow, I might have a different events:state input followed by different checks but which use the same service call.

Would that be a need to duplicate the service call node or link back to the previous flow?

I guess my query is when to link and when to duplicate?

I did have my lighting control on one flow once but it was massive and very hard to follow/debug. It’s currently broken down into many flows but there are many connections also from motion detection, presence detection, even the media control flow has links into the lighting flows.

I don’t use links from page to page. There is nothing wrong with doing that, it’s just my preference. I use links on the same page if there are too many lines criss crossing.

I use grouping on pages to break up my different areas. If I need the same service call on another page, I add another node. It really comes down to what makes sense to you. I wouldn’t worry about duplicating nodes for different flows.

1 Like

Very helpful, thanks.

I never knew you could group sections like that :flushed:

I like the idea of no inter-flow links as well, that would help me a bit, I guess way back I was concerned about having duplicate nodes, I’ll re-think now and tidy-up.

I do tend to use a lot of same-flow links and junction nodes - my flows like just like wiring diagrams with all the wires running parallel, maybe a bit of OCD there I think.

1 Like