What is Node Red

Node-RED is an open-source graphical development tool that helps you rapidly create applications, especially event-driven applications, like IoT applications. It can be installed anywhere node.js can run, including IoT devices like a Raspberry Pi, BeagleBone, Intel Edison, or ran on docker based cloud systems like CommunityGrid or Docker Desktop.

What this flow does

In essence this flow will monitor 2600 Off the wall and Off the hook rss feeds (or any other rss feed one adds) and when a new episode is uploaded immediately chromecast it to the display set in “Main Viewscreen”.

This also includes two injection buttons, one for playing temple bells at 07:00 or when clicked. Plus another that on clicked plays bluemars radio.

A final injection button shows how to have Text To Speech casted to chromecast for other automation efforts; including using gotify or other rest based as a notification hub.

How to install

Not much is needed other than the usual setup docker or communitygrid stack outline below:

GitHub Dallas-Makerspace/CommunityGrid VCC Community Grid at Dallas Makerspace. Contribute to Dallas-Makerspace/CommunityGrid development by creating an account on GitHub.

One just needs to deploy the following docker-compose.yml file then import the code’s flow json. Be sure to update the “main viewscreen” node to use your chromecast’s ip since the one provide is using an example zerotier address.

Requirements

This flow uses a few extras to function. Particularly:

flows.nodered.org node-red-contrib-chromecast NodeRED nodes to for Chromecast

flows.nodered.org node-red-node-feedparser A Node-RED node to get RSS Atom feeds.

These can be added by visiting the Pallet Manager located by selecting Menu > Manage palette > Install tab.

Importing the flow

Node-RED has a great guide on importing flows. But the basics of it is as follows.

Visit the Node-RED flow view. Select the Hamburger Menu > Import. Paste in the json data for the flow. Select the Import button.

Once one imports the flow it should look like the one below.

Docker swarm compose file

--- version: "3.7" networks: default: external: true name: 'public' services: node-red: image: nodered/node-red:latest ports: - "1880" volumes: - node-red-data:/data volumes: node-red-data: ...

Code

[{"id":"60ae904.a77327","type":"tab","label":"media","disabled":false,"info":""},{"id":"c7e80187.faa41","type":"chromecast-play","z":"60ae904.a77327","name":"Main Viewscreen","url":"","contentType":"","ip":"192.168.195.2","x":1090,"y":420,"wires":[[]]},{"id":"968dd682.0abd58","type":"feedparse","z":"60ae904.a77327","name":"Off the Hook Feed","url":"https://www.2600.com/oth.xml","interval":"9600","x":110,"y":220,"wires":[["9c6d86d3.fc6a08"]],"icon":"font-awesome/fa-feed"},{"id":"9c6d86d3.fc6a08","type":"function","z":"60ae904.a77327","name":"getEnclosureURL","func":"if(!msg.article){

node.error(\"No article received\");

return;

}



msg.payload = {

url: msg.article[\"rss:enclosure\"][\"@\"].url,

contentType: 'audio/mp3',

}



return msg;

","outputs":1,"noerr":0,"x":350,"y":220,"wires":[["9156274d.b80be8"]]},{"id":"9156274d.b80be8","type":"join","z":"60ae904.a77327","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\

","joinerType":"str","accumulate":false,"timeout":"","count":"10","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":220,"wires":[["90f60d85.04ee"]]},{"id":"90f60d85.04ee","type":"sort","z":"60ae904.a77327","name":"","order":"ascending","as_num":true,"target":"payload","targetType":"msg","msgKey":"","msgKeyType":"elem","seqKey":"payload","seqKeyType":"msg","x":670,"y":220,"wires":[["e9eeeb96.16fa58"]]},{"id":"e9eeeb96.16fa58","type":"function","z":"60ae904.a77327","name":"latestEpisode","func":"msg.payload = msg.payload[0];

return msg;","outputs":1,"noerr":0,"x":820,"y":220,"wires":[["784504bc.ba63bc"]]},{"id":"6af41439.fca64c","type":"comment","z":"60ae904.a77327","name":"Mapreduce EnclosureURL","info":"","x":610,"y":180,"wires":[]},{"id":"2fd4c6ce.ead36a","type":"feedparse","z":"60ae904.a77327","name":"Off the Wall Feed","url":"https://www.2600.com/otw.xml","interval":"9600","x":100,"y":280,"wires":[["9c6d86d3.fc6a08"]],"icon":"font-awesome/fa-feed"},{"id":"252a6b27.d3e8b4","type":"inject","z":"60ae904.a77327","name":"start bells","topic":"bells","payload":"{\"url\":\"http://soundbible.com/grab.php?id=2079&type=mp3\",\"contentType\":\"audio/mp3\"}","payloadType":"json","repeat":"","crontab":"00 07 * * *","once":false,"onceDelay":0.1,"x":370,"y":420,"wires":[["da5f4943.3b6a18"]]},{"id":"da5f4943.3b6a18","type":"json","z":"60ae904.a77327","name":"","property":"payload","action":"obj","pretty":false,"x":630,"y":420,"wires":[["c7e80187.faa41"]]},{"id":"784504bc.ba63bc","type":"delay","z":"60ae904.a77327","name":"","pauseType":"queue","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"90","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1020,"y":220,"wires":[["c7e80187.faa41"]]},{"id":"67ff0f4c.6b80c","type":"inject","z":"60ae904.a77327","name":"start bluemars stream","topic":"bluemars","payload":"{\"url\":\"http://streams.echoesofbluemars.org:8000/bluemars\",\"contentType\":\"audio/mp3\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":360,"y":500,"wires":[["da5f4943.3b6a18"]]},{"id":"a5723501.ce4d58","type":"inject","z":"60ae904.a77327","name":"Say hello world.","topic":"bluemars","payload":"{\"url\":\"http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&tl=En-gb&q=Hello%20World.'\",\"contentType\":\"audio/mp3\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":380,"y":580,"wires":[["da5f4943.3b6a18"]]}]

Extra reading