Hear about essential Node-RED 4.0.2 updates that you'll find in the latest groov EPIC and RIO version 4.0 firmware.
Included in groov EPIC and groov RIO is Node-RED, an open-source software program you can use to wire together devices, databases, cloud applications, and APIs (application program interfaces) with simple logic flows.
Are you using Node-RED in your current projects? Curious to see if the latest version of Node-RED has updates that could affect your applications?
Read on to see what technical updates to expect and what changes you'll want to take advantage of right away.
With groov firmware 4.0, Node-RED is also now at its 4.0 version. Specifically, groov EPIC and groov RIO are running Node-RED v4.0.2 at the time of writing. One major change with this version of Node-RED is that Node.js now has a minimum requirement of v18. Going to v20 in the latest EPIC & RIO firmware, we are jumping straight to the long-term support (LTS) version for better compatibility with future updates.
With that technical stuff out of the way, what kind of changes will you actually see in use?
Right up front, you will get much better support for the latest versions of non-core node packages. This improved compatibility will make it much easier for new users to get the functionality they need without having any downside for people with existing projects. The quality-of-life improvements don’t stop there; the editor has seen some nice upgrades that make flows easier, faster, and smoother to build and maintain. Let's take a look at some highlights.
The editor updates include improved autocomplete, which now autocompletes flow and global context variables. These variables are critical to keeping data persistent between flow executions or sharing data between flows, and leveraging them unlocks many possibilities in your projects. Having autocomplete support makes these variables easier to work with, and saves a lot of time spent referencing the context storage tab.
If you’re not familiar with context variables or how to use them, you can check out this complete overview video on YouTube.
One of the most common nodes that flows start with is the inject node. By default, when you drag in an inject node, it will instantiate with `msg.payload` as the timestamp in the format of “milliseconds since epoch.” This commonly used standard time does contain useful data and can be manually converted to an actual date and time, but `1754713242123` is not very readable to the human eye.
To help with this, Node-RED 4.0 now lets you inject a pre-formatted date instead! It has the same default behavior, so it’s not too sudden a change for existing users who have been used to milliseconds since the epoch. However, these other formats are much more useful and readable.
The ISO time format is commonly used by databases, showing from years down to milliseconds in a string with a consistent length and consistent GMT timezone. The JavaScript “Date” object allows you to perform functions to easily get any part of the current time separately, as well as access many pre-formatted options.
You can learn more about JavaScript date formatting on the Opto Forums.
A big feature of Node-RED that is often overlooked and underutilized is subflow support. Subflows let you take a small flow or group of nodes that you plan to reuse repeatedly, but sometimes you need to tweak each one slightly. For example, you may be pulling data in, modifying it, and then returning it out. The way it’s modified and the endpoint may stay the same, but the source you’re pulling from might change every time. It can be tedious to set up and maintain without subflows, but leveraging them allows you to reuse your work as often as needed. If you have done any programming, you might think of them as a subroutine.
With Node-RED 4.0, it’s now also straightforward to change the configuration of the contained nodes all from the settings in the individual instance of the subflow node. Some examples might be setting a different MQTT broker, a different database endpoint, or a different groov device. Being able to do this makes subflows even more dynamic and useful, so now is the perfect time to check them out if you haven’t given them a go before.
There are a lot of other smaller or more niche improvements and additions — like updated JSONata and an overhauled CSV node — and also bigger changes to how Node-RED behaves when multiple users are accessing and editing flows on a server simultaneously. If you want a complete breakdown of the new features and access to the complete patch notes, check out these links:
These are all great resources that we at Opto often leverage to get the most out of Node-RED.
Happy flowing!