@mschaeffler/node-red-init 2.1.0

Node for initialisation of context storages.

npm install @mschaeffler/node-red-init

@mschaeffler/node-red-format

Node for initialisation of context storages.

The reason behind this node is: If you initialize a flow or global context variable in the startup code of a function node, it is possible, that other nodes already access the variable before the startup code is executed! So with this node, you do not get this race conditions.

At the start of a NodeRed flow, a flow or global contaxt variable can be initalized with a defined value, if is not already defined. With input messages it can also be set or reseted to the initalisation value.

image of nodes

Install

$ npm install @mschaeffler/node-red-init

init

initialises a flow or global context variable.

Input

If the msg property invalid is present in the message, the message is ignored.

If msg.reset is set or msg.topic==="init", the variable is set to the initialisation value.

Otherwise the variable is set to msg.payload.

Parameters

config type description
Name string name of the variable
Value str,num,bool,json initialisation value
global boolean set in global context
force boolean set at every startup, even if variable is already set

Example Flow

example flow

Author

Mathias Schäffler

License

LGPL-2.1

Node Info

Version: 2.1.0
Updated 1 month ago
License: LGPL-2.1
Rating: not yet rated

Categories

Actions

Rate:

Downloads

6 in the last week

Nodes

  • init-flow

Keywords

  • node-red

Maintainers