Turning Join and NodeRED into a RSS notification system

Who needs RSS readers when you have Join and NodeRED

Join 2.0 has been released. Ther are few extra things we can do with it now. One of which is sending URL in Join notifications. I figured it would be nice to showcase this to you guys, and João came up with a neat idea. You can turn NodeRED and Join node into a pretty awesome RSS notification system. If you are obsessed with news and updates from various sites, you can get your RSS updates without any RSS apps installed on your phone or a computer.  Here is how!

RSS notification system

The setup is pretty simple. Each time a new post has been posted, we are going to issue a Join message with a title, icon, link and a brief description of the post. This should take only a few clicks.

But first things first, if you don’t have the Join node – check this tutorial out. If you do, and you feel comfortable with NodeRED – you have to install one more node:

sudo npm install node-red-node-feedparser

Or use the Palette Manager. If you just starting with NodeRED – check my tutorial for beginners first.

Now that we have everything ready – let’s start the flow:

The feedparse node will ask you for the URL of the website you want to get the new posts from. In this example I’m using AndroidPolice, they post often enough to get this tested quick:

https://www.androidpolice.com/feed/

I want the Join messages to look nice, so I’m going to create the title and assign the icon for each notification. I could embed this into the function code, but I know for sure I will be adding multiple sources, so using the change node is much more forward-thinking:

To set the Join title & icon we need to assign the following values:

msg.title = Android Police
msg.icon  = https://lh4.googleusercontent.com/-2lq9WcxRgB0/AAAAAAAAAAI/AAAAAAAAETw/Yk2jY1eiZss/photo.jpg

Next, I’m using a function node to process the information from the feed node:

The Function Node code
if(!msg.title){
    node.error("Must provide a notification title");
    return;
}

if(!msg.article){ 
    node.error("No article received");
    return;
}
var article = msg.article;
if(!article.date){ 
    node.error("Article has no date. Can't check.");
    return;
}

var globalName = msg.title.replace(" ","_").toLowerCase() + "RssDate";

var date = Date.parse(msg.article.date);
var lastAp = global.get(globalName) || 0;

if(date<lastAp) return;

global.set(globalName,date)
msg.date = date;

msg.push = {
    "title":msg.title,
    "text":article.title,
    "url": msg.topic,
    "icon":msg.icon
};
return msg;

In short, there are three if statement to handle the potential errors. Then I process the outcome from the feedparser to receive the URL and description of the article.

These values are saved JSON object:

{ "title":msg.title, "text":article.title, "url": msg.topic, "icon":msg.icon }

and send as the msg.push to Join node. At the time of the writing, Join node has not been updated with the detailed description but here are the values that Join can receive:

FILL THIS IN

The RSS notification system will push new updates every 5 min, and deliver it to a Join device of your choice.

Adding multiple sources to RSS notification system

Instead of complicating the script in the node function, I used the change node to set the source related properties. I can simply duplicate the source and the change node enable additional sources without modifying the script.

It’s a very easy way of adding the sources. My advice is to store all the icons for your Join messages as shared pictures on a Gdrive. If the public link to the icon changes, you won’t have to update the RSS notification system.

But please, let me sleep!

To keep the notifications quiet during the night hours, you could use a bigtimer node and the flow enable/disable routine.

Install the bigtimer node using npm:

node-red-contrib-bigtimer

set the duration (ie 10am – 5pm) and link the 1st output to a change node. This node will set the flow.rss value as msg.payload received from the bigtimer (set to false/true as ON/ OFF Msg.

During the quiet times, I will override the Join push notification’s priority to the lowest. This way, the phone won’t make annoying sounds at night, and I won’t miss any of the RSS updates. I can do so by setting the msg.push.priority value to -2 (scale is from -2,-1,0,1,2) as the default value is 2. Outside of my scheduled hours, the notification priority will return to the default value (2).

To decide which route the new RSS topic should go, I will use a switch node in the flow.rss mode. The node will have a string (not an integer – see bigtimer output) 1 and 0 output, this way I can control what direction the RSS push is going.

Conclusion

As you can see, in this fun way you can replace the RSS app on your phone, and still get notifications from your favourite sources. The set up takes less than 5 min and you could use it to display the feed to other devices too (smart mirrors, custom displays etc).

Hope you learned the new ways of pushing information using Join node.

Support NotEnoughTech
A lot of time and effort goes into keeping NotEnoughTech alive! If my work helped you out, consider buying me a coffee or check out exclusive rewards available to Patreon supporters.
SHARE