node-red-contrib-fff-random-number 1.0.0

A Node-RED node to generate random numbers with configurable range and precision.

npm install node-red-contrib-fff-random-number

node-red-contrib-fff-random-number (random-number)

Generates a pseudo-random number between min and max, allowing you to choose the number of decimal places. Returns the result in msg.payload and displays it in the node status.

Installation

To install locally or from a repository:

cd %HOMEPATH%\.node-red
npm install node-red-contrib-fff-random-number

After restarting Node-RED, you will find the node under function with the label random number.

Configuration

Field Description Default
name Label visible in the editor. ""
min Minimum range value. 0
max Maximum range value. 1
decimals Number of decimal places (0 = integer). 0

Dynamic Inputs

You can override the node configuration by sending the following properties in the input message:

  • msg.min: Overrides the minimum value.
  • msg.max: Overrides the maximum value.
  • msg.decimals: Overrides the number of decimal places.

Note: If these properties are not present in the message, the values configured in the node will be used.

Input and Output

  • Input: Any message triggers the generation of a new number.
  • Output: msg.payload contains the generated number (type Number).

Example Flow

You can import the example included in the examples folder or use the following JSON:

[
  {
    "id": "inject",
    "type": "inject",
    "name": "Every 5 s",
    "repeat": "5",
    "once": true,
    "wires": [["random-number"]]
  },
  {
    "id": "random-number",
    "type": "random-number",
    "name": "Simulated Temperature",
    "min": 18,
    "max": 26,
    "decimals": 2,
    "wires": [["debug"]]
  },
  {
    "id": "debug",
    "type": "debug",
    "name": "Monitor",
    "tosidebar": true
  }
]

Best Practices

  • Use decimals according to the precision you need to avoid numerical noise.
  • You can chain this node with smooth or delay to build more realistic signals.

Contributing 🤝

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

See CONTRIBUTING.md for more details.

Node Info

Version: 1.0.0
Updated 2 weeks, 3 days ago
License: ISC
Rating: not yet rated

Categories

Actions

Rate:

Downloads

84 in the last week

Nodes

  • random-number

Keywords

  • node-red
  • random
  • number
  • generator
  • fff

Maintainers