Is there a way to spawn multiple instances of a subflow from a single sequence?

Have been using NR very successfully in conjunction with the Hubitat Elevation smart hub for the past year or so. Have been overwhelmed by the awesomeness of the NR platform + HE community developed nodes.. :exploding_head:

One aspect of my home automation system is to create some sequences for home or away. In order to do this I am using the "node-red-contrib-presence-faker" node. This node sets some randomized timing for execution which I can configure and control through messages - it allows me to have lights/devices whatever turn on/off on a semi-random timer. Unfortunately for my purposes I want have to have a PF node for each device rather than a group of them. I can do this the manual way of course but it starts to get rather unwieldy the more HE device nodes I add.

I would like to be able to create a subflow and pass in a list of devices and then loop through said list and separately instantiate the PF node for each device. I've got enough experience to handle the looping/parsing etc so am not worried about that bit.

My question is - does the subflow do this already, instantiate separate PF nodes based on each message in the loop or do they get overwritten/replaced each time? I have looked at the docs and am unclear about that in terms of nodes.

If it does get overwritten is there a way to dynamically instantiate nodes in a subflow or dynamically generate multiple instances of a subflow in a sequence?

Any thoughts would be appreciated...

Anyone have any thoughts on this? :thinking:

Each subflow is an instance of whatever you have inside.

If you have one instance of the subflow you have one pf node. If you have 2 instances of your subflow, you effectively have 2 lots of whatever is inside (i.e. 2 pf nodes).

Unless the pf node supports dynamically creatable multiple schedules, it won't be possible either in or out of a subflow.

There are potentially other solutions but will require some work on your part. For example, the cron-plus node supports as many schedules as you wish and is 100% programmable/dynamic - but you would need to handle the variance of things (e.g. if you want an output at 7:30 +/- 30 mins, you'd have to set the schedule for 7:15 with a 30min random delay) but it is definitely possible to achieve what you're asking. (note I don't use nor do I know what this pf node does so there is some speculation on my part)

1 Like

Thanks for the heads up. Yeah thats kind of what I figured. Your idea about cron-plus is an interesting one - I have used it for other things so will explore a little further...

:+1:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.