Clackapedia

Clackapedia


October 2016
M T W T F S S
« Jul   Nov »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Categories


The Instant Burrito Button

clackapediaclackapedia

On Prime Day this year, I picked up several Amazon Dash buttons, intending to play around with them to make them do interesting things. Having heard about the mods, I figured I’d give it a shot myself. Finally, I went into it, and was able to make a dash button that orders me chipotle! Want to know how to do so yourself? Read on!

You will need the following in order to follow along:

Ok, lets get started!

Get That Linux Ready

First thing we are going to do, is make sure we have our linux server ready to go. This program runs on Node.JS, using the node-dash-button and chipsandguac npm libraries, so we will load all are prerequisites:

sudo apt-get install libpcap-dev  
sudo apt-get install npm  
sudo apt-get install nodejs-legacy  
npm install node-dash-button  
npm install chipsandguac  

Get your Dash on!

Next step, we need our amazon dash button to be ready to be utilized, so we need to get it up in running. In your amazon app, go to ‘your account’ then within look for the section ‘dash devices’. Click on ‘Set Up a new device’. Follow all the steps in the app, but STOP when the app asks you what item you want it to order when you press the button. At this point you have all you need to keep going.

Find your dash

The first thing we need to do, is find out the MAC address of your dash button, now that it’s configured, it will try to talk on your network. Having followed the steps above and installed node-dash-button you have all you need to find it!

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

This program looks on your network for specific network requests. While it is running, press the dash button. You should see output like this while it is running:

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: f0:27:2d:8f:04:d4 Manufacturer: Amazon Technologies Inc. Protocol: udp  
Possible dash hardware address detected: 48:5d:36:8f:f0:43 Manufacturer: Verizon Protocol: arp  

You see the 1st one that says “Manufacturer: Amazon Technologies Inc”? That’s your amazon dash hardware address. Take a note of it we’ll need it later.

A quick look at the dash code

Below is the dash code using the MAC hardware address from the previous step. All this will done when run is say “omg found” on the console, but this can be changed to anything. Later on we will combine this code with the chipotle code to make the button order your burrito.

var dash_button = require('node-dash-button');  
var dash = dash_button("f0:27:2d:8f:04:d4", null, 60000, 'all');  
// hardware address, choose specific network interface, time to wait for button in ms, look for specific network protocol from dash
dash.on("detected", function (){  
    console.log("omg found");
});

begin the chipotle!

Now that we have our dash info, we need our chipotle info! We are going to use the chipsandguac library in order to find our Chipotle we are going to always online order from.

Create a .js file with the following information, replace ZIP with your zip code.

var ChipsAndGuac = require('chipsandguac');

ChipsAndGuac.getNearbyLocations("ZIP").then(function(locations) {  
  console.log(JSON.stringify(locations));
});

You will get output like this:

[
  { id: 1430, name: '8100 W. Crestline Ave' },
  { id: 644, name: '3170 S. Wadsworth' },
  { id: 970, name: '5699 S. Broadway' },
  { id: 71, name: '12512 W. Ken Caryl Ave.' },
  { id: 390, name: '333 W. Hampden Ave.' }
]

The important thing here, is we are going to get the ID number of our pressed chipotle from this step and use it for the next one.

Find that order!

With this next step, we are going to query your favorite store for the order number of your last few orders

var ChipsAndGuac = require('chipsandguac');

// instantiate a new ChipsAndGuac object, passing in required configuration and credentials.
var cag = new ChipsAndGuac({  
  email:'EMAIL_GOES_HERE',
  password:'PASSWORD_GOES_HERE',
  locationId: 'LOCATION_ID',
  phoneNumber:'555.555.5555' // must match user profile
});

cag.getOrders().then(function(orders) {  
  console.log(orders);
});

This program should get you the following output:

logging in...  
login success!  
location XXXX homepage success!  
[ { id: 73917274,
    name: 'Recent Order #1',
    items: [ [Object], [Object] ] },
  { id: 68265115,
    name: 'Recent Order #2',
    items: [ [Object], [Object], [Object], [Object], [Object], [Object] ] },
  { id: 67377130,
    name: 'Recent Order #3',
    items: [ [Object], [Object] ] },
  { id: 67183347,
    name: 'Recent Order #4',
    items: [ [Object], [Object] ] },
  { id: 66595936,
    name: 'Recent Order #5',
    items: [ [Object], [Object] ] } ]

This gives you order ID of the last 5 items you have ordered at the chipotle that matches your location ID

You can log into chipotle.com and confirm these items to move to the next step, or just write the following next code with each of the ids until you find the one you want.

Make sure you keep the ‘true’ variable in the next bit of code while you are working on this, if you remove it, or replace it with false, you will complete an online order:

var ChipsAndGuac = require('chipsandguac');

var cag = new ChipsAndGuac({  
  email:'EMAIL_GOES_HERE',
  password:'PASSWORD_GOES_HERE',
  locationId: 'LOCATION_ID',
  phoneNumber:'555.555.5555' // must match user profile
});
//replacing the true with false, or removing turns this from a preview to ordering
cag.submitPreviousOrderWithId(67377130, true).then(function(orderDetails) {  
  console.log(orderDetails);
});

When executed, you will receive the following output:

logging in...  
login success!  
location xxxx homepage success!  
order initialized  
logged in  
location xxxx homepage success!  
items from order xxxxxxx added to order xxxxxxxx  
pay in store selected  
order review success  
pickup times found  
order ready for submit. { pickupTimes:  
   [ '10/13/2016 3:45:00 PM',
     '10/13/2016 4:00:00 PM',
     '10/13/2016 4:15:00 PM',
     '10/13/2016 4:30:00 PM',
     '10/13/2016 4:45:00 PM',
     '10/13/2016 5:00:00 PM',
     '10/13/2016 5:15:00 PM',
     '10/13/2016 5:30:00 PM',
     '10/13/2016 5:45:00 PM',
     '10/13/2016 6:00:00 PM',
     '10/13/2016 6:15:00 PM',
     '10/13/2016 6:30:00 PM',
     '10/13/2016 6:45:00 PM',
     '10/13/2016 7:00:00 PM',
     '10/13/2016 7:15:00 PM',
     '10/13/2016 7:30:00 PM',
     '10/13/2016 7:45:00 PM',
     '10/13/2016 8:00:00 PM',
     '10/13/2016 8:15:00 PM',
     '10/13/2016 8:30:00 PM',
     '10/13/2016 8:45:00 PM',
     '10/13/2016 9:00:00 PM',
     '10/13/2016 9:15:00 PM',
     '10/13/2016 9:30:00 PM',
     '10/13/2016 9:45:00 PM' ],
  items: 
   [ { name: 'clackapedia',
       itemName: 'Chicken Burrito Bowl',
       itemDetails: 'White Rice, Fajita Veggies, Pinto Beans, Roasted Chili-Corn Salsa, Cheese' },
     { name: 'clackapedia, itemName: 'Small Soda', itemDetails: '' },
     { name: 'clackapedia',
       itemName: 'Additional Instructions',
       itemDetails: 'May I have double rice and fajita veggies? Thx!' } ],
  location: 'locationaddress' }
using first available pickup time:  10/13/2016 3:45:00 PM  
preview is enabled, so skipping place order step  
{ pickupTimes: 
   [ '10/13/2016 3:45:00 PM',
     '10/13/2016 4:00:00 PM',
     '10/13/2016 4:15:00 PM',
     '10/13/2016 4:30:00 PM',
     '10/13/2016 4:45:00 PM',
     '10/13/2016 5:00:00 PM',
     '10/13/2016 5:15:00 PM',
     '10/13/2016 5:30:00 PM',
     '10/13/2016 5:45:00 PM',
     '10/13/2016 6:00:00 PM',
     '10/13/2016 6:15:00 PM',
     '10/13/2016 6:30:00 PM',
     '10/13/2016 6:45:00 PM',
     '10/13/2016 7:00:00 PM',
     '10/13/2016 7:15:00 PM',
     '10/13/2016 7:30:00 PM',
     '10/13/2016 7:45:00 PM',
     '10/13/2016 8:00:00 PM',
     '10/13/2016 8:15:00 PM',
     '10/13/2016 8:30:00 PM',
     '10/13/2016 8:45:00 PM',
     '10/13/2016 9:00:00 PM',
     '10/13/2016 9:15:00 PM',
     '10/13/2016 9:30:00 PM',
     '10/13/2016 9:45:00 PM' ],
  items: 
   [ { name: 'clackapedia',
       itemName: 'Chicken Burrito Bowl',
       itemDetails: 'White Rice, Fajita Veggies, Pinto Beans, Roasted Chili-Corn Salsa, Cheese' },
     { name: 'clackapedia', itemName: 'Small Soda', itemDetails: '' },
     { name: 'clackapedia',
       itemName: 'Additional Instructions',
       itemDetails: 'May I have double rice and fajita veggies? Thx!' } ],
  location: 'location address' }

Putting it all together!

Now that we know the ordering piece alone works, we will add this into the dash code in order to make the dash button order your code. I will make the code below for the final product set in preview mode still, so you don’t copy, past and accidentally order a burrito. Just change the true to false in cag.submitPreviousOrderWithId() and you will actually order the burrito bowl.

var ChipsAndGuac = require('chipsandguac');

// instantiate a new ChipsAndGuac object, passing in required configuration and credentials.
var cag = new ChipsAndGuac({  
  email:'EMAIL_GOES_HERE',
  password:'PASSWORD_GOES_HERE',
  locationId: 'LOCATION_ID',
  phoneNumber:'555.555.5555' // must match user profile
});
var dash_button = require('node-dash-button');  
var dash = dash_button("f0:27:2d:8f:04:d4", null, 60000, 'all'); //address from step above  
dash.on("detected", function (){  
cag.submitPreviousOrderWithId(67377130, true).then(function(orderDetails) {  
  console.log(orderDetails);
});
});

What we have done here is change the on press function, to order our burrito.

I will update this post in the near future with a video walk through. Until then, use your new found power wisely!

Comments 0
There are currently no comments.