Skip to content

Instantly share code, notes, and snippets.

@freakent
freakent / gist:8186221
Created December 30, 2013 18:53
Cheerlights Node-Red flow.
[{"id":"52247c3a.addb84","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"1041920c.efbe6e","type":"twitter in","twitter":"","tags":"cheerlights","user":"false","name":"","topic":"tweets","x":130,"y":136,"z":"edece394.12132","wires":[["d15fbafe.2ea048","ad98649a.526798"]]},{"id":"d15fbafe.2ea048","type":"debug","name":"","active":true,"complete":false,"x":542,"y":125,"z":"edece394.12132","wires":[]},{"id":"5d084303.a2f7bc","type":"mqtt out","name":"","topic":"smartstar/in","broker":"52247c3a.addb84","x":547,"y":240,"z":"edece394.12132","wires":[]},{"id":"ad98649a.526798","type":"function","name":"Cheerlights","func":"// Extract colours from Twitter String\n\nvar input = msg.payload;\nvar colours = input.toUpperCase().match(/\\b(red|blue|green|purple)\\b/ig);\nif (colours == null) { return }\n//console.log(\"colours:\" + colours);\n\nvar pattern = [];\ncolours.forEach(function(colour) {\n var cc = (colour == \"RED\") ? \"P\" : colour.charAt(0);\n \n console.log(\"Colour:\" + co
@freakent
freakent / gist:8186161
Created December 30, 2013 18:50
Node-Red function for extracting colours from a Cheerlights Twitter message.
// Extract colours from Twitter String
var input = msg.payload;
var colours = input.toUpperCase().match(/\b(red|blue|green|purple)\b/ig);
if (colours == null) { return }
//console.log("colours:" + colours);
var pattern = [];
colours.forEach(function(colour) {
var cc = (colour == "RED") ? "P" : colour.charAt(0);