How to setup and run Node-Red

Node-Red is IBM open source project for wiring things on internet. It was started by IBM’s Emerging Technology Services team and now is part of JS Foundation,

For anyone who has been a fan of Yahoo Pipes the interface and functioning seem similar. Node-Red connects different parts of the web together regardless of whether they are hardware or software services. Node-Red is flexible enough to run on cloud and as well on your raspberry pi (another interesting option is old Android Phone). In this tutorial we will setup a Node-Red instance and get info from our devices.

My use flows are much like IFTTT recipes. I prefer self-hosted solutions and hence Node-Red. It’s also true that there are hundreds of user contributed flows that made me use it. For example node-red-contrib-couchdb that allows connection to CouchDB database, which is my preferred database.

Install and setup

There is a single click Deploy to Cloud for IBM Cloud. It does everything required. If you just want to explore then use Docker version on your laptop. I have used it on a Pi, Android phone and on cloud without any issues. Make sure to enable and change the admin password. Once you install it, start node-red and access the same at http://ip_address:1880

The next step is to design your flow (similar to IFTTT recipe).

Setup your flow

Here I am designing an example flow using HOPCOMS API which we had designed earlier. There is package called node-red-contrib-couchdb you can use it to setup the CouchDB database access. But in our case we can just do a HTTP Request using the standard CouchDB HTTP APIs.

https://data.thejeshgn.com/hopcoms_daily/_all_docs?limit=3&descending=true&include_docs=true
Setting up simple onion rate alert.

Setting up simple onion rate alert.

//function getLatestOnionRate

payload = msg.payload;
rows = payload["rows"];
latest = rows[2];
latest_id = latest['id'];
latest_rates = latest['doc'];
onion_rate = latest_rates["163"];
onion_rate = onion_rate+"";
return {"onion_rate":onion_rate};

//mustache template
Onion Price: {{onion_rate}} !

API Access

There are many user contributed nodes and flows for hardware control. For example, huemagic to control all your hue stuff. For example at home I have a netatmo and I want to receive alert when there is noise around. Start with netatmo and pushover node installation. You need to create Apps with both netatmo and pushover (Developer account). The provide the right keys to the Node-Red to configure. Here in the below example I get an alert on my mobile if the sound level is more than 35db (I can configure this). And I have configured this to check netatmo every 5 mins or so. I know it’s not useful for sound but it’s really useful for temperature and other weather related stuff.

Using Netatmo and Pushover API to get weather alerts.

Using Netatmo and Pushover API to get weather alerts.

End Note

Node-Red is highly configurable with its user contributed flows and nodes. Just be a little experimental and you will be surprised.

1 Response

  1. May 2, 2021

    […] was running Node-RED on an android phone for a while, and then I moved it to dedicated Pi. Now that I have Synology capable of running […]