Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get matt-dasher to run #5

Open
PianSom opened this issue Oct 2, 2017 · 6 comments
Open

Can't get matt-dasher to run #5

PianSom opened this issue Oct 2, 2017 · 6 comments

Comments

@PianSom
Copy link

PianSom commented Oct 2, 2017

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!

@stjohnjohnson
Copy link
Owner

stjohnjohnson commented Oct 3, 2017

What does your config file look like?

@PianSom
Copy link
Author

PianSom commented Oct 3, 2017

`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
Copy link
Author

PianSom commented Oct 3, 2017

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
Copy link
Author

PianSom commented Oct 3, 2017

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
Copy link
Author

PianSom commented Oct 4, 2017

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
Copy link
Author

PianSom commented Oct 4, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants