Node-Red Example Flows and Projects

The idea of this page is to present simple example flows or sub flows that solve a particular problem, and that can be used as part of larger projects.

If you have any suggestions then I would be glad to hear them just use the comment form at the bottom of the page.

If you would like to be notified when I add a new flow/project then please sign up for the newsletter

In addition there are much larger and more complex flows that I have create to solve a particular problem which are contained in the projects category and that you may also find useful.

Example Flows


Projects


Find Tasmota Devices

A simple flow to find and display details of all the Tasmota devices on your local network. There is a more detailed flow description on my other site-find tasmota devices

https://www.buymeacoffee.com/steveh5u/e/192899

Set Text Colour Of Text Dashboard Widget

The goal here is to change the text colour in a dashboard text widget but can also be applied to other widgets.

The flow consists of an inject node that send a simple text string and a change node to set payload properties for the colours. continuedset-colored text

Splitting a Message Payload

In this simple project we will look at splitting a simple message payload, and then display the data in a text box and on gauges on a dashboard.

The payload consists of a simple string containing temperature and humidity readings separated by a ampersand (&). continued

Simple Keypad for Node-Red Flows

Download

————

Display last x Messages

Will display the last x messages. x is 10 by default and can be changed in the code.

Flow Diagram

last-messages-display

Download

Read File line by Line

Some time you need to step through a file line by line. This simple flow lets you do that by using the nodejs readlines module.

The video is here that describes how it works:

and the flow is here

SubFlows

MQTT Topic Filter

Filtering out MQTT topics is a common task and this sub flow makes this easy to implement.

The filter is available here and I did a explanation video here to help you use it.

Value Compare SubFlow

Most flows have hard comparison which is quick and easy to implement but not very flexible.

The idea of this subflow is make the comparison flexible by passing the condition into the flow along with the values.

Here is a video showing how to use it:

The demo flow from the video contains the subflow and is here Note: the subflow has had slight changes since the video and now displays the status.

Temperature Converter

Converts from centigrade to Fahrenheit and vice versa.

Pass in the conversion as c,f,centigrade or Fahrenheit on the topic and the value in msg.payload.
if the topic is a c or centigrade then the value is treated as a Fahrenheit value to be converted to centigrade.
A demo flow containing the subflow is here

Flatten JavaScript Object

A subflow that takes an incoming nested JavaScript object and creates a flat object. Subflow can be downloaded here

Click to rate this post!
[Total: 3 Average: 3.7]

14 comments

  1. Hi Steve,

    If there the table of devices had a date/time stamp in one field, is there a handy way to select a date range to get a list of devices from that range displayed rather than the entire list?

    It would tidy up some tables for easier viewing.

    Redgs,

    Rob

      1. Hi Steve,

        The table has entries a few times an hour and grows daily. At the moment I am looking at pulling in from an SQL database and showing the data on a table. That bit is ok. It would be fine if the date range is too difficult to do, to have a display of weekly, monthly and quarterly on a table, even its on a new table.

        I can export the table as a CSV if it makes the task easier and just display the exported CSV in a table.

        Once data is written, that data never changes. Each new entry for say sensor ‘A’ becomes a new entity in itself and has all the same fields as the other entries. Hope that makes sense.

        Many thanks and best regards,

        Robert

  2. Hi Steve, I have already read a lot of information from you and given my thanks very detailed.

    what I would like to do is to convert data via API locally or from the internet to modbus registers which I can then read out in a PLC, I can use modbus IP for this, what I can manage is that I can connect between NodeRed and my PLC via modbus, however, I can’t manage to set up the right registers mainly they are analogue values, temperature, humidity, wind direction, but also generation data from my solar panels. do you have one or more examples 16 and 32 bit how i can make a good modbus register from API data?

  3. ok for this example
    but with different length, different subjects.
    but how can I SPLIT this data in separate data:
    ID,TEMP,HUM,BAT
    example:
    payload
    20;0A;wx1;ID=5cf8;TEMP=00e7;HUM=36;
    20;7A;wx2;ID=9610;TEMP=00e1;BAT=OK;
    20;81;wx3;ID=9421;TEMP=00e6;

    Dick

    1. Assume that the data is a string. split on :
      using
      let data=payload.split(“;”)

      you now have an array of elements. You could split each one on = so you finish up with two elements temp and the value for example. then you need to do a string search to get temp,bat etc.
      Does that make sense.
      Rgds
      Steve

  4. Hi Steve. I’m having difficulty getting a PIR sensor to switch on a light. Both are flashed with Tasmota.
    I can see the correct topic for the motion sensor being ON or OFF (stat/porch/PIR1).
    In Node-Red I have the MQTT Node which subscribes to that topic and debug successfully shows ON or OFF.
    I have an MQTT publish Node which is for sending an on or off command to the light switch.

    But then I’m really stuck as to what goes in between.
    I’m really stumped. Every thing I search for always mentions Home Assistant, and never just Node-Red like I want.
    Any advice much appreciated. Thanks.

  5. Hello Mr.steve I am currently doing my college project I have an deployment error unauthorized due to invalid credentials.Please help to sort out.

  6. Hello Mr. Your blog is good. So i have many question about MQTT. because now i’m making a exam project about mqtt. Could I get have your contact email ?

Leave a Reply

Your email address will not be published. Required fields are marked *