mqtt-dasher icon indicating copy to clipboard operation
mqtt-dasher copied to clipboard

Can't get matt-dasher to run

Open PianSom opened this issue 7 years ago • 6 comments

Hi

I have installed matt-dasher. but (1) the install instructions have installed what I suspect to be the previous version of the code (I use a non-standard port and username/password, so this did not work). I manually copied the current code to server.js on my machine (2) Even after this I cannot get matt-dasher to run. I get the following error:

info: Connecting to MQTT at mqtt://192.168.1.202 /usr/lib/node_modules/mqtt-dasher/server.js:95 winston.info('Listening for %d buttons', Object.keys(config.buttons).length); ^

TypeError: Cannot convert undefined or null to object at setupButtons (/usr/lib/node_modules/mqtt-dasher/server.js:95:57) at /usr/lib/node_modules/mqtt-dasher/node_modules/async/dist/async.js:3853:24 at replenish (/usr/lib/node_modules/mqtt-dasher/node_modules/async/dist/async.js:946:17) at iterateeCallback (/usr/lib/node_modules/mqtt-dasher/node_modules/async/dist/async.js:931:17) at /usr/lib/node_modules/mqtt-dasher/node_modules/async/dist/async.js:906:16 at /usr/lib/node_modules/mqtt-dasher/node_modules/async/dist/async.js:3858:13 at MqttClient. (/usr/lib/node_modules/mqtt-dasher/server.js:89:13) at emitOne (events.js:101:20) at MqttClient.emit (events.js:188:7) at MqttClient._handleConnack (/usr/lib/node_modules/mqtt-dasher/node_modules/mqtt/lib/client.js:732:10)

Any suggestions? Thanks!

PianSom avatar Oct 02 '17 14:10 PianSom

What does your config file look like?

stjohnjohnson avatar Oct 03 '17 03:10 stjohnjohnson

`mqtt: # Specify your MQTT Broker's hostname or IP address here host: 192.168.1.xxx port: 1884 #leave empty if none username: xxx password: xxx # Preface for the topics $PREFACE/$TOPIC preface: dash

buttons: 18:74:2e:1f:xx:xx: wilkie`

PianSom avatar Oct 03 '17 06:10 PianSom

As I copied the config I noticed the lack of spaces before the button Mac address.

I put a couple in and ran with sudo and all seems happy! I can't test right now as I am not at home.

PianSom avatar Oct 03 '17 06:10 PianSom

No joy, I'm afraid.

I get to "Waiting for dash buttons to be pressed" but the Pi I am running it on does not seem to be receiving any button presses.

I know this to be the case, because I can run the following js script on another machine and get the "Button pushed!" message, but do not get it on the Pi (running 'sudo node code.js')

Perhaps this is some kind permissions problem? But I am at a loss as to how to track it down ...

code.js:

`var dash_button = require('node-dash-button'),
  dash = dash_button('18:74:2E:1F:xx:xx'), //redacted
  exec = require('child_process').exec;

   dash.on('detected', function() {
   console.log('Button pushed!');
    });`

PianSom avatar Oct 03 '17 13:10 PianSom

My button broadcasts on udp (as found by running node-dash-button's find_buttons, which reports

Possible dash hardware address detected: 18:74:2e:1f:xx:xx Manufacturer: unknown Protocol: udp 

I have tried amending server.js, so that the appropriate set up line reads

buttons[macAddress] = DashButton(macAddress, null, null, 'udp');

Still no joy :(

However, making the same amendment to the code.js above DOES allow my Pi to see the button!

PianSom avatar Oct 04 '17 08:10 PianSom

OK, I found the problem

At it's core the issue is that my Dash button only uses udp. This, combined with the fact that the install managed to find an old version of your code meant that not only did server.js need to be replaced, but also an old and deprecated version of node-dash-button was installed in mqtt-dasher's node_modules.

So the steps to me getting it to work were 1 - install from github as per your instructions 2 - copy server.js manually from here to the mqtt-dasher directory 3 - edit the new server.js to pass 'udp' (as my previous post) ('all' may also work, didn't check) 4 - install current version of mqtt-dash-button, and ensure that this version is linked in to mqtt-dasher's node_modules

PianSom avatar Oct 04 '17 10:10 PianSom