I'm early into my adventure with Node-RED. I have a pattern that I expect to be repeating quite a lot in my flows. I've figured out that I can turn it into a subflow. However, I want to be able to pass "parameters" to it to adjust the behavior and I'm unsure of the best way to accomplish this.
So here's my subflow, which shows a pattern I will use in many places for a bunch of my motion-triggered lights:
The input will be a message triggered by a motion detector state change in Home Assistant. Outside this subflow, I want to be able to (for each instance in which I use it) specify:
- Which entity ID the "Already on?" node should check
- How long the timer node should wait (but default it to 30 minutes if no value is provided)
Basically in coding world this is a function with two parameters, the first one required and the second one optional. What's the right way to set this up? I've been researching variables and context...little lost. Should I be adding message properties before calling the subflow, and then reference those within the nodes' properties? Is that possible?
I'm still getting familiar with the terminology so please speak slowly Thanks for the help.