[OBSOLETE] Amazon Dash Button

Great job, thanks, works perfectly.

I canā€™t get this to work. I can see the dash button mac and it shows up as suchā€¦

[2017-07-17T23:49:48.737Z] [stnp] SmartThings Node Proxy listening at http://:::8081
[2017-07-17T23:49:49.964Z] [stnp] Loaded plugin: dash
[2017-07-17T23:49:59.268Z] [dash] {ā€œaddressā€:ā€œmy-mac-addressā€,ā€œstatusā€:ā€œactiveā€}
[2017-07-17T23:50:14.860Z] [dash] {ā€œaddressā€:ā€œmy-mac-addressā€,ā€œstatusā€:ā€œactiveā€}

I have the smart app configured correctly and all it does is this. I can see that my config is correct because the config file has my ST hub in the notify section correctly.

Also when I click the dash button, it blinks white, then goes through a series of red blinking lights. For added verification I can see in the terminal, messages that show up if I make a change to the smart app from my phone. So they are talking to each other but something is up.

Any ideas?

UPDATE: I can confirm the secret-key is good, all my IPā€™s, ports, I can see any updates to the smart app is seen on the server side, all mac addresses are good, I tried multiple buttons. I just cannot get this to turn on or off any of my switches using the buttons. I see them show up in the logs, but nothing. I have to be missing something simple. Or IDKā€¦ kinda lost on this one.

Looks like everything is setup right on the STNP sideā€¦ letā€™s check the SmartAppā€¦ can you modify the SmartApp lines 141-143 so that they look like this:

  log.trace "SmartThings Node Proxy: ${evt.stringValue}"
  log.trace "Headers: ${headers}"
  log.trace "Body: ${body}"

Re-run your test and have Live Logging up and report back what you seeā€¦ also make sure that the device MAC address are entered into the SmartApp or else the events will be ignored by the SmartApp.

Live logging - you mean what I see on the terminal when the proxy is listening? I just updated the lines 141-143, ensured I have the mac set in the app, clicked the button and I get nothing but the 1 line saying the mac is active. No action on anything else.

I also checked the ST IDE logs and donā€™t see anything.

Yeahā€¦ live logging is the ST IDE logs. Try running this command on your machine (if itā€™s a Linux or Mac):

curl -X NOTIFY -H "Content-Type: application/json" -H "stnp-plugin: dash" -d '{"address":"my-mac-address","status":"active"}' --verbose http://IP_ADDRESS_OF_HUB:39500/notify

And see what shows in the ST IDE logs.

I see this in ST IDE logsā€¦

986af402-159f-4220-b767-945959fead8e 2:33:19 PM: debug Parsing 'index:03, mac:B827EB75CDA5, headers:Tk9USUZZIC9ub3RpZnkgSFRUUC8xLjENClVzZXItQWdlbnQ6IGN1cmwvNy4zOC4wDQpIb3N0OiAxNzIuMjQuMzAuMjAyOjM5NTAwDQpBY2NlcHQ6ICovKg0KQ29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi9qc29uDQpzdG5wLXBsdWdpbjogZGFzaA0KQ29udGVudC1MZW5ndGg6IDQ5, body:eyJhZGRyZXNzIjoiZmM6YTY6Njc6NTI6NmI6NmQiLCJzdGF0dXMiOiJhY3RpdmUifQ==' 051311d6-c62a-4df5-807d-ca998dd42b66 2:32:57 PM: debug Received device event from bridge: [address:fc:a6:67:52:6b:6d, status:active]

And I get a 200 from the curl.

What SmartApp is tied to these ids:

986af402-159f-4220-b767-945959fead8e
051311d6-c62a-4df5-807d-ca998dd42b66

???

You should see those trace messages from the Dash SmartApp that you uncommentedā€¦ the one beginning with SmartThings Node Proxy Those other SmartApps may be blocking the Dash SmartApp from receiving the notifications.

Hmmmā€¦ Looks like my MQTT bridge for HA and ST to talk to each other. But what is odd is that it shouldnā€™t intercept it. I only have MQTT turned on for specific sensors. Iā€™ll try to dig a bit more on this.

I also noticed thisā€¦ I didnā€™t have the right log up. I was looking under the code in the window below. Now that I discovered live logging :)ā€¦ I can see some more.

Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class [B]
[class [C]
[class java.lang.String] @ line 228
4f4a7729-bc1d-46c8-8e69-f471ccf2806d  3:52:42 PM: error groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.lang.String#<init>.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class [B]
[class [C]
[class java.lang.String] @ line 228```

UPDATE: As I dig a bit further, The MQTT bridge sits on the same linux box as the server.js.  Only the MQTT bridge works off of port 8080.  I have the config.json for the server.js using port 8081.  Yet my MQTT bridge is "seeing" the messages come across to the MQTT bridge app in ST.  Very odd.

Yeah - this is a known problem with most SmartApps and Devices. The default method for handling messaging between devices basically maps the IP address to one SmartThing. SmartThings Node Proxy works around this issue but if there are other things that run on the same device as the STNP, there is no guarantee they wonā€™t play nicely. Recommend you remove your MQTT SmartApp/Devices to test or just move the STNP and Dash plugin to another device.

Funny thing, I had STNP running on raspberry pi working fine and decided to add ha-bridge and had the same issue and error as edif30. I did end up removing ha-bridge and everything worked fine again.

Thanks for the explanation.

Oh working great to control my siren or yeelight bulbs but seems the dash button range (blinking red lights)is even less than my xiaomi button but definitely worth more than $1 if not $10, I am using node.js on Pi3 for yeelight control as well as they are listening to different ports seems all are well
I have a question for @redloro though it feel likes it takes a couple of seconds and multiple green light blinks to trigger an action so it feels slower than my xiaomi button, also I saw a couple of red light blinks too, any idea if thatā€™s expected behaviour?
Thanks a lot for good work

Oh seems the red blinks just mean the ordering is not successful, nothing to worry about the wifi range

Yeah - thatā€™s the way the Dash button worksā€¦ takes a couple seconds and flashes its lights.

1 Like

Canā€™t wait to try this, I wanted to post my quick and dirty info on how to use th3 buttons via the Amazon IoT framework with ST My Quick and dirty ST & Amazon IoT Button Integration howto

Got everything to work set up and working with switches. How could I use this to control a routine? Thanks!!

Probably the easiest would be to write your own virtual device that when itā€™s toggled on you run the routine. You may also be able to do this with a virtual device and CoRE?

Hi @redloro, recently the node.js proxy stopped working and I suspect it is due to I have an extra docker network interface, do you have any clue ? i dont know if i could specify an interface

thanks

pi@raspberrypi:~/smartthings-nodeproxy $ node server.js[2017-09-10T14:44:30.522Z] [stnp] SmartThings Node Proxy listening at http://:::8080
[2017-09-10T14:44:30.622Z] [dash] Failed to create pcap session: no devices to listen on...
[2017-09-10T14:44:30.625Z] [dash] Error: socket: Operation not permitted
/home/pi/smartthings-nodeproxy/plugins/dash.js:118
    pcap_session.on('packet', function(raw) {
                ^

TypeError: Cannot read property 'on' of undefined
    at register (/home/pi/smartthings-nodeproxy/plugins/dash.js:118:17)
    at DashButton.init (/home/pi/smartthings-nodeproxy/plugins/dash.js:65:5)
    at Object.<anonymous> (/home/pi/smartthings-nodeproxy/plugins/dash.js:52:6)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
pi@raspberrypi:~/smartthings-nodeproxy $

Well this error is due to the fact that you need to run as sudo. In order to do pcap sessions, you have to run as super user. Try sudo node server.js and see if that works.

Oh IC it works although I have registered it in systemctl I thought it was working before not aware it needs root privileges thanks for that
Is that I need to start it by root using systemctl?

Yes I think soā€¦ sudo needs to launch the nodejs service in order to use pcap.