Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Copyright 2013 IBM Corp. under [the Apache 2.0 license](LICENSE).

**101-scanBLE** - Scans for a particular Bluetooth Low Energy (BLE) device.

**145-BBB-hardware** - A collection of analogue & digital input & output nodes for the Beaglebone Black

### IO

**26-rawserial** - Only really needed for Windows boxes without serialport npm module installed.
Expand Down Expand Up @@ -96,6 +98,8 @@ Uses a simple read of the serial port as a file to input data. You **must** set

**68-mysql** - Allows basic access to a MySQL database. This node uses the **query** operation against the configured database. This does allow both INSERTS and DELETES. By it's very nature it allows SQL injection... *so be careful out there...*

**69-ddbout** - Support output to Amazon DynamoDB.

### Time

**79-suncalc** - Uses the suncalc module to generate an output at sunrise and sunset based on a specified location. Several choices of definition of sunrise and sunset are available,
Expand Down
6 changes: 4 additions & 2 deletions analysis/swearfilter/74-swearfilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

var RED = require(process.env.NODE_RED_HOME+"/red/red");
var badwords = require('badwords');
if (badwords.length == 0 ) { return; }
var badwordsRegExp = require('badwords/regexp');

function BadwordsNode(n) {
RED.nodes.createNode(this,n);
var node = this;
this.on("input", function(msg) {
if (typeof msg.payload == "string") {
if (badwords.ok(msg.payload)) { node.send(msg); }
if (typeof msg.payload === "string") {
if ( !badwordsRegExp.test(msg.payload) ) { node.send(msg); }
}
});
}
Expand Down
638 changes: 638 additions & 0 deletions hardware/BBB/145-BBB-hardware.html

Large diffs are not rendered by default.

508 changes: 508 additions & 0 deletions hardware/BBB/145-BBB-hardware.js

Large diffs are not rendered by default.

Binary file added hardware/BBB/icons/BBB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 15 additions & 3 deletions hardware/Pi/78-ledborg.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (!fs.existsSync("/dev/ledborg")) {

function LedBorgNode(n) {
RED.nodes.createNode(this,n);
var p1 = /[0-2][0-2][0-2]/
var p1 = /^[0-2][0-2][0-2]$/
var p2 = /^\#[A-Fa-f0-9]{6}$/
var node = this;

Expand All @@ -36,7 +36,7 @@ function LedBorgNode(n) {
if (err) node.warn(msg.payload+" : No LedBorg found");
});
}
if (p2.test(msg.payload)) {
else if (p2.test(msg.payload)) {
var r = Math.floor(parseInt(msg.payload.slice(1,3),16)/88).toString();
var g = Math.floor(parseInt(msg.payload.slice(3,5),16)/88).toString();
var b = Math.floor(parseInt(msg.payload.slice(5),16)/88).toString();
Expand All @@ -45,7 +45,19 @@ function LedBorgNode(n) {
});
}
else {
node.warn("Invalid LedBorg colour code");
// you can add fancy colours by name here if you want...
// these are the @cheerlight ones.
var colors = {"red":"200","green":"020","blue":"002","cyan":"022","white":"222","pink":"201",
"warmwhite":"221","purple":"101","magenta":"202","yellow":"220","amber":"220","orange":"210","black":"000"}
if (msg.payload.toLowerCase() in colors) {
var c = colors[msg.payload.toLowerCase()];
fs.writeFile('/dev/ledborg', c, function (err) {
if (err) node.warn(msg.payload+" : No LedBorg found");
});
}
else {
node.warn("Invalid LedBorg colour code");
}
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions hardware/blink/77-blink1.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">Expects a msg.payload with three part csv string of r,g,b.</div>
</script>

<script type="text/x-red" data-help-name="blink1">
<p>ThingM Blink1 output node. Expects a msg.payload with a three part csv string of r,g,b.</p>
<p>ThingM Blink1 output node.</p>
<p>Expects a msg.payload with either a three part csv string of r,g,b or a hex colour #rrggbb</p>
</script>

<script type="text/javascript">
Expand Down
34 changes: 29 additions & 5 deletions hardware/blink/77-blink1.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@

var RED = require(process.env.NODE_RED_HOME+"/red/red");
var Blink1 = require("node-blink1");
// create a single global blink1 object
// all blink1 nodes affect the same (single) led
var blink1 = null;

function Blink1Node(n) {
RED.nodes.createNode(this,n);
this.fade = n.fade||0;
this.fade = Number(n.fade) || 0;
var node = this;

try {
var p1 = /^\#[A-Fa-f0-9]{6}$/
var p2 = /[0-9]+,[0-9]+,[0-9]+/
this.on("input", function(msg) {
blink1 = blink1 || new Blink1.Blink1();
if (blink1) {
try {
if (p1.test(msg.payload)) {
// if it is a hex colour string
var r = parseInt(msg.payload.slice(1,3),16);
Expand All @@ -43,17 +48,36 @@ function Blink1Node(n) {
}
else {
// you can add fancy colours by name here if you want...
node.warn("Blink1 : invalid msg : "+msg.payload);
// these are the @cheerlight ones.
var colors = {"red":"#FF0000","green":"#008000","blue":"#0000FF","cyan":"#00FFFF","white":"#FFFFFF","warmwhite":"#FDF5E6",
"purple":"#800080","magenta":"#FF00FF","yellow":"#FFFF00","amber":"#FFD200","orange":"#FFA500","black":"#000000"}
if (msg.payload.toLowerCase() in colors) {
var c = colors[msg.payload.toLowerCase()];
var r = parseInt(c.slice(1,3),16);
var g = parseInt(c.slice(3,5),16);
var b = parseInt(c.slice(5),16);
if (node.fade == 0) { blink1.setRGB( r, g, b ); }
else { blink1.fadeToRGB(node.fade, r, g, b ); }
}
else {
node.warn("Blink1 : invalid msg : "+msg.payload);
}
}
} catch (e) { node.warn("Blink1 : error"); blink1 = null; }
}
else {
node.warn("No Blink1 found");
node.warn("Blink1 : not found");
}
});
var blink1 = new Blink1.Blink1();
this.on("close", function() {
if (blink1 && typeof blink1.close == "function") {
//blink1.close(); //This ought to work but seems to cause more hangs on closing than not...
}
blink1 = null;
});
}
catch(e) {
node.error("No Blink1 found");
node.error("No Blink1 found (" + e + ")");
}
}
RED.nodes.registerType("blink1",Blink1Node);
8 changes: 7 additions & 1 deletion hardware/hue/104-hue_manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
</select>
</div>

<div class="form-row">
<label for="node-input-brightness"><i class="icon-tag"></i>Change Brightness (0->100):</label>
<input type="text" id="node-input-brightness" placeholder="brightness">
</div>

<div class="form-row">
<label for="node-input-color"><i class="icon-tag"></i>Select color:</label>
<input type="text" id="node-input-color" placeholder="color">
Expand All @@ -51,7 +56,7 @@
<script type="text/x-red" data-help-name="HueNode">
<p>This node implements some basic functionality for managing a Philips Hue wireless Lamp system.</p>
<p>To use it you need to have obtained a valid auth token (or username) from your Philips Hue Bridge. Read <a href="http://developers.meethue.com/gettingstarted.html" target="_blank">here</a> on how to do this.</p>
<p>You can enter the ID (1, 2, ...) of a Lamp and turn it ON or OFF and also set its color. </p><p>By setting the status to AUTO, you can set the ON/OFF status as a message payload (e.g., msg.payload="ON") and the color through the message topic (e.g., msg.topic="EBF5FF") on the node input. Please note, in case you use both, the status selection overides the msg.payload!</p><p>Also, if you pass something like msg.payload="ALERT" the Lamp will flash once.</p>
<p>You can enter the ID (1, 2, ...) of a Lamp and turn it ON or OFF, set the color and the brightness (0->100). </p><p>By setting the status to AUTO, you can set the ON/OFF status as a message topic (e.g., msg.topic="1:ON", where 1 is the ID of the Lamp) and the color/brightness through the message payload (e.g., msg.payload="DF0101:50" will set the color to red and brightness to 50%) on the node input. Please note, in case you use both, the msg.payload overrides the node configuration through the UI!</p><p>Also, if you pass something like msg.topic="1:ALERT" the Lamp with ID 1 will flash once.</p>
</script>

<!-- Finally, the node type is registered along with all of its properties -->
Expand All @@ -65,6 +70,7 @@
discovery_mode: {value: "", required:false},
lamp_id: {value:"", required:false},
color: {value:"EBF5FF"},
brightness: {value:"100"},
lamp_status:{}
},
inputs:1, // set the number of inputs - only 0 or 1
Expand Down
57 changes: 41 additions & 16 deletions hardware/hue/104-hue_manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var RED = require(process.env.NODE_RED_HOME+"/red/red");
var gw_ipaddress = "";


var username, lamp_status, lamp_id, color;
var username, lamp_status, lamp_id, color, brightness;

function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
Expand All @@ -54,6 +54,7 @@ function HueNode(n) {
this.lamp_status = n.lamp_status;
this.lamp_id = n.lamp_id;
this.color = n.color;
this.brightness = n.brightness;


// Store local copies of the node configuration (as defined in the .html)
Expand All @@ -65,6 +66,7 @@ function HueNode(n) {
msg.topic = this.topic;

this.on("input", function(msg){
var myMsg = msg;
//set the lamp status
//first locate the Hue gateway:
hue.locateBridges(function(err, result) {
Expand All @@ -84,29 +86,52 @@ function HueNode(n) {
var state = lightState.create();

var status;
if(msg.payload=="ALERT"){
status = "ALERT";
}
else if(node.lamp_status=="ON" || msg.payload=="ON") status = "ON";
else if(node.lamp_status=="OFF" || msg.payload=="OFF") status = "OFF";
var lamp = -1;

//check for AUTO status (lamp settings set through node input)
if(node.lamp_status=="AUTO") {
var color;
var brightness;
//check for lamp ID in the topic
if(myMsg.topic.length>1) {
var tmp_status = myMsg.topic.split(":");
myMsg.topic = tmp_status[1];
lamp = tmp_status[0];
}

//check for brightness & color:
if(myMsg.payload.length>1) {
var tmp_topic = myMsg.payload.split(":");
color = tmp_topic[0];
brightness = tmp_topic[1];
}

if(status=="ALERT") {
api.setLightState(node.lamp_id, state.alert()).then(displayResult).fail(displayError).done();
}
else if(status=="ON") {
if(node.color==null) {
api.setLightState(node.lamp_id, state.on().rgb(hexToRgb(msg.topic).r,hexToRgb(msg.topic).g,hexToRgb(msg.topic).b)).then(displayResult).fail(displayError).done();
//case of ALERT:
if(myMsg.topic=="ALERT"){
api.setLightState(lamp, state.alert()).then(displayResult).fail(displayError).done();
}

//case of ON:
if(myMsg.topic=="ON") {
api.setLightState(lamp, state.on().rgb(hexToRgb(color).r,hexToRgb(color).g,hexToRgb(color).b).brightness(brightness)).then(displayResult).fail(displayError).done();
}
else {
api.setLightState(node.lamp_id, state.on().rgb(hexToRgb(node.color).r,hexToRgb(node.color).g,hexToRgb(node.color).b)).then(displayResult).fail(displayError).done();
api.setLightState(lamp, state.off()).then(displayResult).fail(displayError).done();
}

}
else {
api.setLightState(node.lamp_id, state.off()).then(displayResult).fail(displayError).done();
//set lamp according to node settings
if(node.lamp_status=="ON")
api.setLightState(node.lamp_id, state.on().rgb(hexToRgb(node.color).r,hexToRgb(node.color).g,hexToRgb(node.color).b).brightness(node.brightness)).then(displayResult).fail(displayError).done();
else
api.setLightState(node.lamp_id, state.off()).then(displayResult).fail(displayError).done();
}

msg2.payload = 'Light with ID: '+node.lamp_id+ ' was set to '+status;
if(lamp!=-1)
msg2.payload = 'Light with ID: '+lamp+ ' was set to '+myMsg.payload;
else
msg2.payload = 'Light with ID: '+node.lamp_id+ ' was set to '+node.lamp_status;
node.send(msg2);
}
else {
Expand Down Expand Up @@ -142,4 +167,4 @@ var displayError = function(err) {

// Register the node by name. This must be called before overriding any of the
// Node functions.
RED.nodes.registerType("HueNode",HueNode);
RED.nodes.registerType("HueNode",HueNode);
File renamed without changes
54 changes: 0 additions & 54 deletions hardware/hue_discover/103-hue_discover.html

This file was deleted.

Loading