node-red-contrib-fff-random-number 1.0.0
A Node-RED node to generate random numbers with configurable range and precision.
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.payloadcontains the generated number (typeNumber).
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
decimalsaccording to the precision you need to avoid numerical noise. - You can chain this node with
smoothordelayto 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.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
See CONTRIBUTING.md for more details.