lutzer / node-red-contrib-finite-statemachine

A finite state machine implementation for node red.
MIT License
16 stars 5 forks source link

Node Red State Machine

A finite state machine (FSM) implementation for node red. Displays also a graphical representation of the state machine.
node-appearance

Installation

In Node-RED

In a shell

Usage

You can find detailed usage information in the Usage Manual.

Node Configuration

node-settings

Basic FSM structure

The statemachine of finite state machine is defined by a JSON object within the line FSM (Finite State Machine):

{
  "state": {
    "status": "IDLE"
  },
  "transitions": {
    "IDLE": {
      "run": "RUNNING"
    },
    "RUNNING": {
      "stop": "IDLE",
      "set": "RUNNING"
    }
  }
}

Input

The input topics of the finite state machine are defined by the transition table setup in the node configuration.

Output

The output of finite state machine sends a msg whenever there is a valid transition. Remark: This also may be a valid transition without any state change.

The payload contains:

Further information

Check Node-REDs info panel to see more information on how to configure the state machine.

Example


Remark: Example flows are present in the examples subdirectory. In Node-RED they can be imported via the import function and then selecting Examples in the vertical tab menue.


For more examples, read the Usage Manual.

Minimal state machine

This example shows a state machine with two states. There is only one msg.topic ("toggleState") which toggles between the two states IDLE and RUNNING.

{
  "state": {
    "status": "IDLE"
  },
  "transitions": {
    "IDLE": {
      "toggleState": "RUNNING"
    },
    "RUNNING": {
      "toggleState": "IDLE"
    }
  }
}

flow-minimal MinimalStateMachineFlow.json

Changelog

Changelog.txt

Development