Code Monkey home page Code Monkey logo

node-red-contrib-actionflows's Introduction

node-red-contrib-actionflows

ActionFlows brings easy to use loops and OOP (object oriented programming) features to Node-RED's flow programming paradigm. Three nodes allow you to create extensible, scoped, looped, and prioritized flows. Utilities include performance benchmarks with nanosecond precision. Advanced use enables the ability to group flows into "libraries" using Node-RED's native subflow capabilities and invocation via JavaScript. You can organize flows for readability and create extendable design patterns. To understand ActionFlows, review each section starting with Basics below and each section's examples.

Basics

The following example of ActionFlows' action node does nothing! "Hello World" is placed in the msg.payload and passes through the action node and can be seen in the debug output; but it's use and versatility can be illustrated with the followup descriptions.

Action Node Basics

ActionFlows' initial purpose was to allow for "after market" flow extendability. Complex flows can be customized without modifying the original author's flow. This technique can also be used to organize your existing flows for readability, but links and subflows maybe better suited for that single purpose. ActionFlows provide additional key functionality (described later in this document):

  • "Late binding"; extend complex flows without modifying the original flow
  • Looping; call flow segments repeatedly with conditional iteration
  • Create OOP-like "classes" (subflows) with public/private flows
  • Prioritize flows; allow for OOP-like overrides & inheritance
  • Flow scopes; private, protected, and global flows

Simply include the action flow inline at specific points where you would like to enable vendor customization. Like Node-RED's native subflows, a description field allows you to create optional API (application programming interface) documentation. The action node works like a subflow, allowing you to define a reusable flow segment between the nodes action in and action out. Flow execution resumes like Node-RED's native links node with "virtual wires" at the action in node and returns to the calling action node after encountering the action out node.

Action In/Out Basics

Unlike the links node, the action node invokes the action in node by a prefix naming schema; allowing for multiple add-on flow segments to be appended to the original flow. An action node's name determines the name of the corresponding action in node that will be activated. Use the action node's name as a prefix for all subsequent action in nodes that you wish to be callable by the action node. For instance, an action node named "Sample", will call any action in nodes with names like "Sample in", "Sample-in", "Sample_Exercise", or "sample.acme.com".

A prefix is an existing `action` node's name followed by
a space, hyphen, underscore, or a period.

If present, ActionFlows will invoke multiple matching prefix named nodes sequentially. By default, the sequence order is by creation order but can be changed using the action in node's Priority property.

ActionFlows Sequence

In the example above:

  1. The action node is encountered with msg.payload containing "Hello World".
  2. The action in node (named "action in") is called, changing "World" into "World, and Solar System!".
  3. The action in node (named "action 2") is called after the last action out node and "World" is replaced with "Mars".

The versatility of ActionFlows allows the adding of additional flow sequences after the original flow has been authored. The action in node's flow segments can be created or imported dynamically (such as with the flowman node). Flows can be defined on other tabs or within subflows (see the "Libraries and Scope" section below) or restricted to the same tab or subflow where the calling action node has been defined.

Flow sequence order can also be changed by the action in node's settings (see the "Priorities" section).

Download the Basic example flow here.

Benchmarks and Debugging

Benchmarks in the action node allow you to see how long all action in flow sequences take to execute. Use the checkbox labelled "Debug action cycle execution time" to see debug output indicating how long it took to run all of the corresponding action in/out flow segments before returning to the calling action.

ActionFlows Benchmarks

Note: Benchmarks report how long it takes to run all matching action in/out flows for one given iteration. Loops return to the action node before repeating and may generate multiple debug outputs.

Use the "Debug invocation sequence" checkbox to reveal the name of each action in that is called, it's sequence order, and node id in the debug tab.

Priorities

Priorities allow you to define ActionFlows that take precedence over other ActionFlows. Inspired by WordPress' core actions and filters API, Priorities are at the heart of manageable extendability. In our Basic example sequence we see that two action in/out flow segments have been defined; each changing the "Hello World" in msg.payload to eventually become "Hello Mars, and Solar System!". However, if we simply change the action in/out flow sequences, we end up with "Hello Mars" in the msg.payload.

ActionFlows Priorities

Here we modify the node "action in" and "action 2" to execute in the reverse order thus changing the debug output message. Open the settings for the nodes and change the Priority for "action 2" to 45 and leave "action in" with Priority 50 (the default). Now when the action node is encountered, it will seek out the action in/out flows and run them in a different sequence; the lower the Priority number the earlier the flow order will be executed. Two flows with the same Priority number will execute sequentially starting with whichever flow was defined first.

Priority numbers can vary between 1 to 99. The lower the number, the earlier a defined flow segment will execute. I.e. An action in node with #1 priority executes before a #2 priority, etc. It is recommended that you leave the priority numbers at their default of 50 to allow overrides by other authors (if need be). Often times, multiple vendors or "plugin" authors may provide future functionality that are priority dependent. For example, a localization/translation service plugin may want to change their Priority for their action in/out flow to 95 to ensure that their flow sequence runs last. Thereby ensuring that they have all messages at hand that might need to be translated from one spoken language to another; even if other plugin authors include their action in/out flows leveraging the same action node.

Nesting

ActionFlows can be nested whereby a flow segment can include an action node that in turn, invokes additional action in/out flow segments. One way to trace an ActionFlows' sequence is to use the "Debug invocation sequence" checkbox or, (as illustrated below) by using the delay node. Be sure to set the delay to above 2 seconds to see the blue dot appear in the action in/out flow path and for the green dot and "running" indicator under the active action node. Please see the animated gif below.

ActionFlows Nesting

In this simple animation, the main action node calls two defined flows; one action in/out node called "action in" and another called "action in 2". The "action in 2" flow contains an action node called "nested" that invokes the action in/out node named "nested in". The first action node waits until all other flows and nested flows complete their sequence. Watch the end of the animation above to view an overlay showing the complete flow path.

Download the Nesting example flow here.

Loops

The action node allows execution of action in/out node segments based on a conditional loop. The default loop mode for an action node is "none" for no looping. Use the Looping drop down combobox to select the loop type.

ActionFlows Looping

Note: The action node icon will change from a lightening bolt to a circular arrow to indicate the action is in loop mode.

In our example below, we will select the option "Increment from zero". This option is followed by the variable we'd like to use in our conditional loop. The "...from zero" ensures that the variable will be initialized to contain the numeric value 0 when the action node is first encountered in the given flow. The variable will be incremented by a numeric 1 each time all corresponding action in/out nodes have completed. An initial check of the condition occurs before each iteration. In this case, we will check if the variable msg.loop is greater than 2; causing the loop to iterate three times (0, 1, 2).

ActionFlows Increment from zero

The msg.loop variable is accessible to our change node allowing us to inject it into a string and output the count to the debug window. When the flow is run, the debug window should show three separate outputs; "Testing 0", "Testing 1", and "Testing 2" before execution of the flow is stopped.

Download the Loops example flow here.

Looping Modes

The Looping options in the drop down combobox are defined as follows:

None

No Looping. The action node will seek out any defined action in nodes and will call them sequentially, one time only.

Watch

Watch the given variable and compare it using the set logic operator with the comparison variable/value; sequentially invoke each of the defined action in nodes until the set logic operator evaluates to true. Note: the variable should already exist prior to encountering this node. The logic condition is checked before the first loop iteration.

Decrement

Decrement the given variable after each loop iteration. Note: the variable should already exist prior to encountering this node. The logic condition is checked before the first loop iteration, followed by calling each defined action in flow. The decrement operation occurs after all defined action in flows have completed.

Increment

Increment the given variable after each loop iteration. Note: the variable should already exist prior to encountering this node. The logic condition is checked before the first loop iteration, followed by calling each defined action in flow. The increment operation occurs after all defined action in flows have completed.

Increment From Zero

When a flow initially invokes the action node, the given variable will be reset to zero. If the variable does not exist, it will be created. The logic condition is checked before the first loop iteration, followed by calling each defined action in flow. The increment operation occurs after all defined action in flows have completed. The looping will continue until the logic condition evaluates to a logical true.

Until Conditional Logic Operator

The loop mode will continue until the given conditional logic operator evaluates to a logical true. The Until options in the drop down combobox are defined as follows:

== (equals)

Checks if the given variable is equal to the comparison variable or value.

!= (not equals)

Checks if the given variable is not equal to the comparison variable or value.

< (less than)

Checks if the given variable is less than the comparison variable or value. Note: the given variable and comparison variable/value should contain numeric values.

<= (less than or equal to)

Checks if the given variable is less than or equal to the comparison variable or value. Note: the given variable and comparison variable/value should contain numeric values.

> (greater than)

Checks if the given variable is greater than the comparison variable or value. Note: the given variable and comparison variable/value should contain numeric values.

>= (greater than or equal to)

Checks if the given variable is greater than or equal to the comparison variable or value. Note: the given variable and comparison variable/value should contain numeric values.

contains

Checks if the given variable contains the value in the comparison variable/value. Note: the given variable and comparison variable/value should contain string data.

not contains

Checks if the given variable does not contain the value in the comparison variable/value. Note: the given variable and comparison variable/value should contain string data.

Libraries and Scope

Scope provides functionality for flows that are more commonly found in OOP (object oriented programming) environments. Using scopes with ActionFlows allows you to build reusable flow libraries that may act as a base for other flows. Regardless of the scope setting, action nodes will invoke all matching action in flows that are on the same "z plane" (same tab or within the same subflow). However, there are many benefits to using the different scope modes and in different combinations. Here are the three main levels of scope which define ActionFlows' behaviors:

global

The "global" scope is the default mode. The "global" setting allows you to use ActionFlows across multiple tabs or within different subflows. An action node will invoke any action in flow segment across the system, regardless of where they are defined (within subflows or other tabs). Flows will be invoked if the action in node's name begins with the name of the corresponding action node. Use the global scope to allow other developers to extend a flow on their own tab or without having to modify an existing flow no matter where it is located (i.e. deep within a subflows). Placing a group of global ActionFlows within a subflow is an easy way to distribute modular behaviors or add vendor specific functionality.

protected

Using the "protected" scope setting for ActionFlows allows you to group functionality while avoiding conflicts with common names that could occur with global scope. Unlike global scope, protected scope restricts action and corresponding action in nodes to the same tab. Furthermore, protected scope places restrictions on accessing ActionFlows within a subflow; you may still access them but must first declare a prefix that is the subflow's name. This allows you to work with multiple subflows as object instances in a similar fashion that OOP developers use classes and objects with public or private methods.

ActionFlows Scope: Protected

ActionFlows can address other ActionFlows within subflows using an explicit prefix to identify the subflow location of other ActionFlows nodes. The prefix is the name of the subflow where the corresponding action or action in node exists. In the screenshot above we have two examples:

An example of an action node calling a flow segment defined outside the subflow. 1a) The subflow is defined on the tab with the name "acme", it is invoked with an injector supplying the string "Hello". 1b) The injector activates the subflow's action node named "action". 1c) The flow segment outside the subflow is found by the name acme.action because the action in node's name starts with the subflow name and the action node's name within it "action".

The flow segment contains a change node that alters the "Hello" and changes it to "Hi".

An example of a flow segment defined inside a subflow and accessed from outside. 2a) The action node named "acme.sample in" finds the defined flow segment inside the subflow named "acme". 2b) Within the "acme" subflow is the action in node named "sample in".

The flow segment has a change node that changes the injector's "Hello" string to "Good bye".

Download the Protected Scope example flow here.

The following namespace-like rules apply to using ActionFlows with "protected" scope inside of subflows:

  • Both action and action in names must match within a subflow. I.e. an action named "sample" will invoke any action in beginning with the name "sample". The subflow name as a prefix is not necessary from inside the subflow.
  • ActionFlows defined outside of the subflow must declare the subflow name as apart of the prefix. For example, an action node named "apple" within a subflow named "fruits" could invoke an action in node at the tab level if the action in node's name begins with the subflow name, i.e. "fruits.apple". Likewise, sub-subflows (subflows that exist within subflows) would require additional prefixes to address the innermost node.
  • Protected scope nodes can only invoke one another within the same tab.
Note: Changing the name of a subflow may require a "Full Deploy" to update
ActionFlows' internal namespace map changes.

private

Private flows are useful if your actions have a commonly used name and/or you wish to restrict extendability to within a subflow or tab. Unlike protected scope, private scope inhibits the ability to invoke or respond to ActionFlows that are defined outside of the given subflow or tab where the ActionFlows exists. Using private scope helps avoid naming conflicts but prevents extensibility.

Mixed Scope Modes

Note that both action and action in nodes have a scope setting. For example within a subflow, a global scope action next to private scope action in will have a unique ability; this pattern ensures that the internal private action in is always invoked once within the subflow and only for that subflow instance. Any other action in nodes of the same name elsewhere could also be called but the internal action in can never be invoked from other instances of the subflow.

Scope Icons

Scope settings are reflected in the ActionFlows node icons. The icons for action in nodes, action nodes (in single or loop mode) will depict a small "hint" icon in the upper right hand corner to indicate the scope setting.

Scope Hint Icons

ActionFlows and JavaScript

ActionFlows creates a global object called "actionflows" that you can obtain a reference to in JavaScript. The object contains a number of data structures and methods that determine the runtime behavior of ActionFlows. For instance, the ActionFlows' action in nodes can be pragmatically invoked using Node-RED's native JavaScript function node. To invoke a given action in node, you will need to obtain a reference to the "actionflows" global object. Line 1 in the screenshot below shows how to get a reference to "actionflows" in the variable af. From there you may use the af object's invoke method to call an existing action in node (line 2). The invoke method expects two parameters; the first should be a string representing the name that any matching action in node should begin with. The second should be the msg object to be passed into the matching action in node.

JavaScript invoke

In the given screenshot, the JavaScript function node invokes the action in node with the name "action". The flow is executed and appends the string " World" to the injector node's "Hello" resulting in "Hello World" in the debug window.

Download the JavaScript Invoke example flow here. Note: the JavaScript Invoke example requires the string node.

The actionflows global object contains the following methods and properties of interest:

Methods

invoke - Invokes any matching action in nodes with the name found in the first parameter. The second parameter should be the msg object to be passed into the flow segment. A promise object is returned with a single incoming parameter containing the returned msg object. Note: the invoke method ignores scope settings and can be used to invoke any action in node by name.

map - The map method processes all the found action and action in nodes and builds an associative map. This method is called once internally at deployment and determines the order in which each action in node is called for it's corresponding action node. The results are updated in the actions property (see below).

Properties

actions - An object containing the calculated associative map from the map method (defined above) that is used internally by ActionFlows. The map is a list of enabled action node instances with a special ins property containing corresponding, action in node instances based on their priority and scope settings. The map allows ActionFlows to quickly execute sequential flows at runtime. Editing this list will alter the ActionFlows behavior (use with caution). The object can be reset by recalling the map method or re-deploying to restore the original design-time flow settings.

afs - An object containing all the action nodes in the system. This property is used internally by the map method to determine the runtime behavior of ActionFlows. Altering this list prior to calling the map method will permanently change the runtime behavior of ActionFlows. Alteration is not recommended as this will disable the ability to reset the behavior until re-deployment.

ins - An object containing all the action in nodes in the system. This property is used internally by the map method to determine the runtime behavior of ActionFlows. Altering this list prior to calling the map method will permanently change the runtime behavior of ActionFlows. Alteration is not recommended as this will disable the ability to reset the behavior until re-deployment.

Reserved Action Names

Currently, ActionFlows has only one reserved action in node name:

#deployed

Any action in nodes that start with "#deployed" in their name will be invoked at deployment. This would be the equivalent of pairing an inject node with the option for "Inject once at start" set to invoke a flow segment defined by ActionFlows. The action in node named "#deployed" will also contain a msg.payload object property that references the parent container the action in node lives in (i.e. a tab or subflow).

#deployed Event

This feature can be used to obtain the subflow instance name should you require a reference to it within your subflow object instance. In addition, the Node-RED runtime instance's settings are exposed in msg.settings allowing your flows to know the uiPort, settingsFile folder, httpRoot, etc.

Download the #deployed event example flow here.

Installation

Run the following command in your Node-RED user directory (typically ~/.node-red):

npm install node-red-contrib-actionflows

The ActionFlows' nodes will appear in the palette under the advanced group as the nodes action, action in, and action out.

node-red-contrib-actionflows's People

Contributors

aabluedragon avatar alonamir-monogoto avatar ratsputin avatar steve-mcl avatar steveorevo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-red-contrib-actionflows's Issues

Node Red crash on full deploy Cannot read properties of undefined (reading 'startsWith')

Hello,

I using Node-Red inside Home assistant plugin and this plugin is installed by default but I don't use it.
When I hit the deploy button Node-Red crashes and restart. Same with all flows disabled.

I get this stack trace :

18 Dec 13:17:49 - [info] Stopping modified nodes
18 Dec 13:17:49 - [info] Stopped modified nodes
18 Dec 13:17:49 - [info] Starting modified nodes
18 Dec 13:17:49 - [red] Uncaught Exception:
18 Dec 13:17:49 - [error] TypeError: Cannot read properties of undefined (reading 'startsWith')
    at map (/opt/node_modules/node-red-contrib-actionflows/actionflows/actionflows.js:297:27)
    at EventEmitter.runtimeMap (/opt/node_modules/node-red-contrib-actionflows/actionflows/actionflows.js:593:5)
    at EventEmitter.emit (node:events:390:28)
    at start (/opt/node_modules/@node-red/runtime/lib/flows/index.js:383:12)
[13:17:50] INFO: Starting Node-RED...

When I disable all 3 nodes of the plugin from the node palette NR don't crash anymore.

I using Node Red 2.1.4 and version 2.0.4 of the plugin

Thanks

nested action won't work

nested_actionflow_error
hi, I'm trying a simple flow with another nested flow but on the second the execution stops
remains in the processing state but does not call the nested in
I also tried to delete and rebuild in the right sequence but it doesn't work

red v1.0.3

thanks a lot

Stop action flow sequence execution when a condition is met

Is it possible to stop executing a sequence action flows (with the same prefix) once a condition is met and continue with next node in the main flow? Let us say there are 3 action flows with "test" prefix (test.one, test.two, test.three). My understanding is that all 3 of them will be executed in sequence based on priority. I am looking for a way to stop executing once a variable (e.g. msg.complete) is set, which can be set by any one of the action flows. If the test.one sets it, then it should immediately return to the main flow and should not execute test.two and test.three. Is there a way to accomplish this in the current version?

Incompatible with NodeRed-2.2.x

Overview

I experience issues trying to call using the Action nodes since upgrading NodeRed to 2.2.0.

The following log entries occur:

2 Feb 13:25:32 - [info] Starting modified flows
2 Feb 13:25:32 - [red] Uncaught Exception:
2 Feb 13:25:32 - [error] TypeError: RED.settings.functionGlobalContext.get is not a function
    at map (/opt/node_modules/node-red-contrib-actionflows/actionflows/actionflows.js:270:51)
    at EventEmitter.runtimeMap (/opt/node_modules/node-red-contrib-actionflows/actionflows/actionflows.js:593:5)
    at EventEmitter.emit (node:events:390:28)
    at start (/opt/node_modules/@node-red/runtime/lib/flows/index.js:383:12)

According to the devs:

We made some internal changes in Node-RED with how global context is managed - and this error is a side-effect of that.

Using RED.settings.functionGlobalContext as way to access global context was never documented as a suitable way of doing it. The fact these nodes are broken because they took that approach, isn't ideal, but nor have we changed a published API.

We need to think about what to do here - should we revert our change to keep things working, or encourage these nodes to use proper APIs.

Reference: https://discourse.nodered.org/t/problem-with-node-red-contrib-actionflows-since-upgrade-to-2-2-0/57368/11

Possibly related to #18

Problems using ActionFlows

Hi,

I've installed your node and imported the first basic flow.
It seems that it doesn't work.

actionflows v2.0
node-red v0.19.4
node.js v8.12.0

Flow does not proceed to next weighted node in chain of events

Recently updated node-red and actionflows on a new server with the same code. Actionflows of the same name do not flow to the next node of higher priority dependably, and instead just stops the flow at the first node of a singular name(.1) instead of flowing to name(.2) of a higher priority like it used to. This renders actionflows somewhat useless as they are unreliable in building a chain of actions.

image image

In this scenario, EnqueueRecord.PFQ would fire, but the following one, EnqueueRecord.PFT does not fire and there are no errors, no warning, and nothing in the logs. It just doesn't execute the follow-on code. This is completely different from actionflows behavior that is documented, and I have personally observed for more than 5 years.

Node-Red v3.0.2
latest version of actionflows

TypeError: prop.indexOf is not a function

The debug panel is showing an error from the action node in my tab/flow. I can't figured out what is causing it.

The actionflow appears to execute once, as I have a function node following the action in node, and a debug node following the function node. The debug node shows the msg object from the first instance/iteration (the function following action in seems to go as expected). I am guessing that the error happens on the second iteration. However, as stated, the error reported is from the action node.

Any ideas how I can troubleshoot this and determine what is causing it to break?

I have another tab, using the same paradigm/pattern (ensures that client npm objects are initialized to connect to databases). It is working fine without issue (which makes it especially confusing as to determining the cause).

Problem with 0.20 version of NodeRed

Dear Stephen,

I upgrade my nodered to the LTS (0.20 version). Since I did that my action flows are not fully working. In particular, they works if action_in and action_out are in a tab (parent flow), however if I put them in a subflow they are not working. I noticed that in the LTS version of nodered, the developers made some enhancements to the subflows part, and I believe that this could have impact in your logic. Are you able to test the action flows with the LTS version of nodered and using subflows?

Cheers,

Giovanni

Action out node does not return to parent node randomly

Hi,

Sometimes when using multiple layers of actionflows (3-4 layers down) the action flow gets stuck "running" and never returns to the parent flow to complete the flow that called it.

For example
Flow -> Action Flow 1 -> Action Flow 2 -> Action flow 3 -> Action flow 4
Action flow 4 completes the flow, but does not return to action flow 3,
if you go to action flow 3 you still see "Running"

Also I don't know how to debug it,
there is no error, and most of the time it works, other times it just gets stuck "Running",
I verified this by putting a debug on the node before the action out node, and the flow does reach there and gets the msg.payload, so the msg.payload is in fact sent to the action out node.

is there a way to force it to finish running somehow via a timer for now or some other workaround?

thanks

Demo protected.json does not work on nodered 2.1.3

Hi to all, I'm doing some test with actionflows (2.1.2) on nodered 2.1.3 (on windows 10 64 bit, node.js 14.18.1) but the example protected.json does not work : acme.action in is not called, why ?

The example is pasted in a separate flow.

action out only returns to parent action when _msgid parameter included in message

Is the design for action out to always depend on input to have _msgid key? It seems that omitting that (as in the case of a new message) results in the flow ending. If the function simple returns a new message without _msgid key then the flow doesn't return, once the key is added (with any data) then the flow properly returns.

Here is simple reference:
image

Flow:

[{"id":"9624ed1d.2f15c","type":"inject","z":"cdb5e574.1b62c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":240,"wires":[["1cb2baa6.a998e5"]]},{"id":"1cb2baa6.a998e5","type":"actionflows","z":"cdb5e574.1b62c8","info":"Describe your action API here.","untilproptype":"num","proptype":"msg","name":"action","prop":"loop","untilprop":0,"until":"gt","loop":"none","scope":"global","perf":false,"seq":false,"x":440,"y":240,"wires":[["66c940e2.f6d4b"]]},{"id":"66c940e2.f6d4b","type":"debug","z":"cdb5e574.1b62c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":640,"y":240,"wires":[]},{"id":"93e9e38c.f6662","type":"actionflows_in","z":"cdb5e574.1b62c8","name":"action in","priority":"50","links":[],"scope":"global","x":120,"y":380,"wires":[["bbb0a7b3.e70898"]]},{"id":"30848d98.b200a2","type":"actionflows_out","z":"cdb5e574.1b62c8","name":"action out","links":[],"x":800,"y":380,"wires":[]},{"id":"e8eff00c.28dc5","type":"function","z":"cdb5e574.1b62c8","name":"test func","func":"\nreturn { \"test\": \"test\" };","outputs":1,"noerr":0,"x":470,"y":380,"wires":[["af3b7207.e008b"]]},{"id":"bbb0a7b3.e70898","type":"delay","z":"cdb5e574.1b62c8","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":300,"y":380,"wires":[["e8eff00c.28dc5"]]},{"id":"af3b7207.e008b","type":"delay","z":"cdb5e574.1b62c8","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":640,"y":380,"wires":[["30848d98.b200a2"]]}]

Initial difficulties

Hi,
I've installed your node and imported the first basic flow.
It seems that it doesn't work.

actionflows v1.2.1
node-red v0.18.2
node.js v8.9.4

how to interrupt an actionflow?

I love your nodes! One thing I could not find out so far: is it possible to interrupt a running actionflow, so that the parent flow is no longer processed any further? (like returning "null" in a function node).

please see the following REST API flow example:
Bildschirmfoto 2021-06-24 um 10 46 57

if the user is not authorized, the secret payload should not be sent.

not triggering the "auth out" node however does not seem to be a proper solution, because it messes with your state management. is throwing and catching an exception recommended? or are there any other options?

what would be the right way to handle this? :-)

Is there a limit to the number of parallel calls to a given actionflow that can be executing simultaneously?

I have a fairly simple actionflow that checks to make sure a ChromeCast Audio is idle before allowing a flow to proceed. The idea being that any time a flow wants to play some audio (text to speech, short MP3, etc.) it calls this actionflow and is stalled until it's okay to play. Basically, a real-world

I'm running into situations where the actionflow is called 3-4x simultaneously from different flows due to multiple events occurring at the same time. Occasionally, it appears that a call just stops executing and the message is never played back. Note, stall time can vary anywhere from 2-3 seconds to as much as 45 seconds; simultaneous calls could be up to five.

Here is the actionflow in question:

[{"id":"f945ecb1.ee5d4","type":"delay","z":"2f09d230.395bfe","name":"Playing; delay 1-3 seconds","pauseType":"random","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"3","randomUnits":"seconds","drop":false,"x":800,"y":480,"wires":[["ed3d98bf.c0f0d8"]]},{"id":"3a49759a.eaf41a","type":"actionflows_in","z":"2f09d230.395bfe","name":"WaitIntercom","priority":"50","links":[],"scope":"global","x":130,"y":460,"wires":[["ed3d98bf.c0f0d8"]]},{"id":"408d7671.3c3638","type":"actionflows_out","z":"2f09d230.395bfe","name":"WaitIntercom","links":[],"x":1110,"y":460,"wires":[]},{"id":"764a736d.68ea5c","type":"comment","z":"2f09d230.395bfe","name":"Wait for intercom to not be busy","info":"","x":330,"y":400,"wires":[]},{"id":"ee19f977.6e2bf8","type":"api-call-service","z":"2f09d230.395bfe","name":"Turn Chromecast Audio on","server":"bd0ac36a.ed0df","version":"1","service_domain":"media_player","service":"turn_on","entityId":"media_player.kitchen_speaker","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":800,"y":520,"wires":[["ed3d98bf.c0f0d8"]]},{"id":"ed3d98bf.c0f0d8","type":"api-current-state","z":"2f09d230.395bfe","name":"Get Chromecast state","server":"bd0ac36a.ed0df","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.kitchen_speaker","state_type":"str","state_location":"state","override_payload":"msg","entity_location":"","override_data":"none","blockInputOverrides":false,"x":340,"y":460,"wires":[["4ef3ae04.92bbe"]]},{"id":"4ef3ae04.92bbe","type":"switch","z":"2f09d230.395bfe","name":"idle/playing/off?","property":"state","propertyType":"msg","rules":[{"t":"eq","v":"idle","vt":"str"},{"t":"eq","v":"playing","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":560,"y":460,"wires":[["408d7671.3c3638"],["f945ecb1.ee5d4"],["ee19f977.6e2bf8"]]},{"id":"bd0ac36a.ed0df","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

I've been working under the assumption that actionflows execute like subroutines and each parallel invocation is independent from any other invocation, storing context on a stack of some sort.

This appears to work reasonably consistently; however, if I run a test, calling it five times in succession, I'll generally only get about three playbacks.

Multimple "action in" work only with "out"

Hi guys. First, many thanks for this lib, it's really useful.

I'm trying to use it to build my own logging trough all tabs. The idea is simple: I gonna put 'action' nodes everywhere I want to log something and 'action in' where I want to read logs, e.g. to put them onto the dashboard.
Here is my example: 2 log 'writers' and 2 readers putting them in log for debugging.
image

Unfortunately it doesn't work: only one 'action in' with lowest priority is called after injection:
image

It works if I put 'action out' after each 'in':
image

But in terms of 'extendability' you mention in the documentation, I can't guarantee that every user listening my events with an 'action in' puts any out after that. It means, every 'client' can break entire injection mechanism.

Or I did understand it wrongly and there is another solution?

"Stuck" at version 0.0.1

$ npm outdated gives me:

Package Current Wanted Latest Location
node-red-contrib-actionflows 0.0.1 0.0.1 1.0.3 my-node-red-project

Looks like for whatever reason actionflow's wanted version is stuck @ 0.0.1
I have not modified my node-red project's package.json - I left it for npm to handle.

If this is intentional - sorry for rising this issue, I'm pretty new to npm & node-red

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.