New kind of Amazon Dash button to start tasks

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

User avatar
Thijsvr
Posts: 21
Joined: Monday 04 January 2016 14:06
Target OS: NAS (Synology & others)
Domoticz version: 2.4075
Location: Amsterdam
Contact:

New kind of Amazon Dash button to start tasks

Post by Thijsvr »

Amazon is releasing a new version of their Dash button specifically aimed at IoT tasks. So no longer predefined tasks, but you can now set your own.
http://www.engadget.com/2016/05/13/amaz ... utton-iot/

Of course you could already mess around with your original Dash buttons like here: https://familab.org/2016/02/hacking-the ... -button-3/

But it's nice that Amazon is now making life a little bit more straightforward.
piotr
Posts: 26
Joined: Monday 15 July 2013 8:17
Target OS: Linux
Domoticz version: Beta
Location: Drenthe
Contact:

Dash buttons now available on Amazon.de

Post by piotr »

The dashbuttons are now available on Amazon.de. On Github are quite a few projects that allow you to use the Dash to trigger actions.

See: https://github.com/hortinstein/node-dash-button
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by Madgeni »

Here's my code to control scenes - (i even handle the lack of 'Toggle') - you need both node-dash-button, as well as the domoticz-api node library.

Needs to be running Sudo (the ARP request packet checker needs elevated privileges).
var Domoticz = require('./node_modules/domoticz-api/api/domoticz');
var dash_button = require('node-dash-button');

var api = new Domoticz({
protocol: "http",
host: "127.0.0.1",
port: 8080,
username: "",
password: ""
});

var dash = dash_button(["ac:63:be:89:c9:b6", "ac:63:be:13:c2:b8", "ac:63:be:02:f7:0b"]);
var on = false;
var idx;

function changeScene(idx, sceneState) {
console.log("state = ", sceneState, " for idx - ", idx);

if(sceneState == 'Off'){
sceneState = 'On';
} else if(sceneState == 'On'){
sceneState = 'Off';
}
console.log("what's the scene state? ", sceneState);
api.changeSceneState({
idx: idx,
state: sceneState
}, function(params, callback) {
return(callback);
});
}

function getScene(idx) {
api.getScenesGroups(function(error, scene) {
// console.log("i'm getting the scenes")
if (error) {
console.log("uhoh - ", error);
}
var sceneArray = scene.results;
for (var i = 0; i < sceneArray.length; i++) {
var element = sceneArray;
if (element.idx == idx) {
var sceneState = element.status;
console.log("scene state is : ", sceneState);
changeScene(idx,sceneState);
}
}
});
}

function callDashButton(dash_id, callback) {
var dict = {
"ac:63:be:89:c9:b6": 6,
"ac:63:be:13:c2:b8": 7,
"ac:63:be:02:f7:0b": 1
};
console.log("Dash button" + dash_id + " was clicked!");
var IDX;
for (var key in dict) {
IDX = dict[dash_id];
// console.log(IDX)
}
getScene(IDX, callback);
}

dash.on("detected", callDashButton);

Last edited by Madgeni on Sunday 11 September 2016 0:12, edited 1 time in total.
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
dhanjel
Posts: 102
Joined: Tuesday 05 August 2014 22:16
Target OS: Linux
Domoticz version: 3.5146
Location: Sweden
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by dhanjel »

Nice, hopefully they will start selling these world wide.

Currently only prime it seems, and to expensive on eBay.

Sent from my Nexus 6P using Tapatalk
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by Madgeni »

It's true that they're only available to Prime customers for now :(
Still, i use Amazon so much that i'm probably breaking even over 12 months by paying for Prime.
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
dhanjel
Posts: 102
Joined: Tuesday 05 August 2014 22:16
Target OS: Linux
Domoticz version: 3.5146
Location: Sweden
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by dhanjel »

yeah, biggest problem with prime though is that it is us only if I am remember it correctly
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by blackdog65 »

yeah, I'm an Amazon.co.uk Prime customer but it's still only available in the US for $19.99
Why do we have to be 2nd place all the time? The poor neighbours.
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
dhanjel
Posts: 102
Joined: Tuesday 05 August 2014 22:16
Target OS: Linux
Domoticz version: 3.5146
Location: Sweden
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by dhanjel »

In sweden we don´t have amazon at all, and no prime :) Easiest is to use a shipping provider like borderlinx, but it gets expensive.
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by Madgeni »

well that's sad :(
I have two you can have if you like?

hmm - I realised last night that won't work - you need to have an account to configure them to connect to your wifi :/
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
pdjm43
Posts: 30
Joined: Friday 12 December 2014 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: UK
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by pdjm43 »

I just had a 'prime' friend order me 2 dash buttons.
Using node-dash-button and requestify.
Here's my code, run in /etc/rc.local -- sudo node /home/pi/node_modules/node-dash-button/node-dash

Code: Select all

#!/usr/bin/env node
var dash_button = require('node-dash-button');
var dash = dash_button(["50:f5:da:11:11:11","ac:63:be:11:11:11"], null, null, 'arp');  //mac address from node-dash-button setup scan
var requestify = require('requestify');
dash.on("detected", function (dash_id){
    if (dash_id === "50:f5:da:11:11:11"){
        //console.log("Dash1");
       requestify.get('http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=325&switchcmd=Toggle');
    } else if (dash_id === "ac:63:be:11:11:11"){
        //console.log("Dash2");
       requestify.get('http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=326&switchcmd=Toggle');
    }
});
So far my first button toggles a pair of lights.

Code: Select all

commandArray = {}
if (devicechanged["Dash1"]) and otherdevices["Dash1"]=="On" then
   commandArray[1]={['Loft 1']='On'}
   commandArray[2]={['Loft 2']='On'}
elseif (devicechanged["Dash1"]) and otherdevices["Dash1"]=="Off" then
   commandArray[1]={['Loft 1']='Off'}
   commandArray[2]={['Loft 2']='Off'}
end
return commandArray
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by woody4165 »

Hi and thanks for sharing this, @pdjm43

In Italy we just got the official Dash button, and I've got one for testing.

I'm trying to install node-dash-button, but I'm getting a lot of errors during installation on my Cubie and also on Raspi.

In any case, I'm also trying to use with other example, like this one

Code: Select all

from scapy.all import *
def arp_display(pkt):
  if pkt[ARP].op == 1: #who-has (request)
    if pkt[ARP].psrc == '0.0.0.0': # ARP Probe
      if pkt[ARP].hwsrc == 'xx:xx:xx:xx:xx:xx': # Huggies
        print "Pushed Something"
      else:
        print "ARP Probe from unknown device: " + pkt[ARP].hwsrc

print sniff(prn=arp_display, filter="arp", store=0, count=10)
But nothing happen.
I've got the Mac address from Fing, an Android app that scan the local network for any device connected, and I see an Amazon one, and I got from there the MAC addr.

But when launching that python code nothing happens, when pushing the button!!!!

Any help where I can check?

I would like to integrate then in domoticz and see what can be an usage.

Thanks
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
pdjm43
Posts: 30
Joined: Friday 12 December 2014 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: UK
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by pdjm43 »

woody4165 wrote:Hi and thanks for sharing this, @pdjm43

In Italy we just got the official Dash button, and I've got one for testing.

I'm trying to install node-dash-button, but I'm getting a lot of errors during installation on my Cubie and also on Raspi.

In any case, I'm also trying to use with other example, like this one

But nothing happen.
I've got the Mac address from Fing, an Android app that scan the local network for any device connected, and I see an Amazon one, and I got from there the MAC addr.

But when launching that python code nothing happens, when pushing the button!!!!

Any help where I can check?

I would like to integrate then in domoticz and see what can be an usage.

Thanks
I only tried node-dash because it was updated recently (they say the dash changed it's output) and it worked straight away. The only advice for your scapy is that the arp scan needs sudo to run.
thebeetleuk
Posts: 115
Joined: Saturday 21 December 2013 23:50
Target OS: Linux
Domoticz version:
Location: Scotland
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by thebeetleuk »

Hi All,

I'm just trying to get my dash button setup and running. As usual I'm being a bit thick in terms of some of the unix setup.

So far I have done the following:
Spoiler: show
https://github.com/hortinstein/node-dash-button

# Dependancy on libpcap for reading packets
sudo apt-get install libpcap-dev

# This took 30 sec to show the install happening....
npm install node-dash-button

cd node_modules/node-dash-button
sudo node bin/findbutton

pi@raspberrypi:~/node_modules/node-dash-button $ sudo node bin/findbutton
Watching for arp & udp requests on your local network, please try to press your dash now
Dash buttons should appear as manufactured by 'Amazon Technologies Inc.'
Possible dash hardware address detected: ac:63:be:8b:6d:8c Manufacturer: Amazon Technologies Inc. Protocol: udp
Possible dash hardware address detected: ac:63:be:8b:6d:8c Manufacturer: Amazon Technologies Inc. Protocol: arp
I'm now a bit stuck on how/what to do in terms of creating and running a script to actually do something.

What file do I create and where?
Does anyone have a template?
How do I get this running on reboot?
do I need to set special permissions?
I heard it has a 4 second delay (assuming to protect against repeat commands?)

Any help would be appreciated :)
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
thebeetleuk
Posts: 115
Joined: Saturday 21 December 2013 23:50
Target OS: Linux
Domoticz version:
Location: Scotland
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by thebeetleuk »

ok so I have read a bit more and have created a file called node-dash.js with some of the suggested code in this. Then I executed with

Code: Select all

sudo node node-dash.js
Unfortunately I get an error :(

Code: Select all

module.js:442
    throw err;
    ^

Error: Cannot find module 'requestify'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/pi/node_modules/node-dash-button/node-dash.js:4:18)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
Now trying to resolve with

Code: Select all

sudo npm update -g
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
thebeetleuk
Posts: 115
Joined: Saturday 21 December 2013 23:50
Target OS: Linux
Domoticz version:
Location: Scotland
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by thebeetleuk »

sudo npm update -g

This didn't work after a reboot. Now stuck again :(
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
thebeetleuk
Posts: 115
Joined: Saturday 21 December 2013 23:50
Target OS: Linux
Domoticz version:
Location: Scotland
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by thebeetleuk »

ok so creating a test file "node-test.js" with the contents "console.log('hello world');" and running "sudo node node-test.js"

returns the desired results :)

so it must be the dependencies within the code thats throwing the error.

Error: Cannot find module 'requestify' <---- Is this the issue? cant it find requestify? A path issue?
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/pi/node_modules/node-dash-button/node-dash.js:4:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
Last edited by thebeetleuk on Monday 05 December 2016 23:09, edited 1 time in total.
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by Madgeni »

Hi -
pimping my code again.
download it - and the node_modules dir from here:
https://github.com/madgeni/domo-dash

create a folder, put it all in there then:

Create Groups in Domoticz, and put the device you want to control in that.
In the domo-dash.js - put your mac addresses in the array,

Code: Select all

//put Dash Mac Addresses here - to find them, use node-dash-button's info: https://github.com/hortinstein/node-dash-button
var dash = dash_button(["ac:63:be:89:c9:b6", "ac:63:be:13:c2:b8", "ac:63:be:02:f7:0b", "50:f5:da:5a:a1:ae"]);
and then again, next to the group IDX (find it in domoticz - setup>devices) here:

Code: Select all

var dict = {
		"ac:63:be:89:c9:b6": 5,
		"50:f5:da:5a:a1:ae": 4,
		"ac:63:be:02:f7:0b": 1
	};
Then run it using :

nohup sudo node dash_control.js &
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
thebeetleuk
Posts: 115
Joined: Saturday 21 December 2013 23:50
Target OS: Linux
Domoticz version:
Location: Scotland
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by thebeetleuk »

got it working!

had to install requestify. doh!

Code: Select all

npm install requestify
once done then it all works :)
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
thebeetleuk
Posts: 115
Joined: Saturday 21 December 2013 23:50
Target OS: Linux
Domoticz version:
Location: Scotland
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by thebeetleuk »

Just curious, what are the advantages of the API over Json calls?
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
Madgeni
Posts: 1571
Joined: Friday 25 March 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New kind of Amazon Dash button to start tasks

Post by Madgeni »

async callbacks via the API call
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest