diff --git a/button-pressed.js b/button-pressed.js index 5495b93..e13ba9b 100644 --- a/button-pressed.js +++ b/button-pressed.js @@ -3,23 +3,27 @@ var dash_button = require('node-dash-button'), module.exports = function(RED) { function node (config) { - + RED.nodes.createNode(this, config); var node = this; - + var mac = config.mac || ''; - - console.log(mac); + var iface = config.iface || undefined; + + node.log('Watching for button with mac address: ' + mac); - var dash = dash_button(mac); + var dash = dash_button(mac, iface, 5000, 'all'); var found = function () { - console.log('Button Pressed: ' + mac); - var msg = {}; + node.log('Dash button pressed: ' + mac); + var msg = { + mac: config.mac, + name: config.name + }; node.send(msg); }; - + dash.on("detected", _.debounce(found, 5000, true)); }; - + RED.nodes.registerType("ButtonPressed",node); -} \ No newline at end of file +} diff --git a/package.json b/package.json index 1034b76..7c24c0f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ } }, "dependencies": { - "node-dash-button": "^0.3.0", + "node-dash-button": "^0.6", "underscore": "^1.8.3" } }