Closed avaidyam closed 9 years ago
since now you have a cheap 5$ button that can toggle any lighting setup you want
At least for 5-10 minutes.
The Dash button is exciting to me, but the fact that you can only use it ONCE over a period of time really takes the wind out of my sails. It's great if you want to use it as some sort of incrementer, but as a "switch" it sort of falls flat.
How long does it actually take to fall back asleep so that you can use it again?
I have a dash and it looks like it takes a few seconds to jump on the wireless, send it's payload, and then drops right off. it all happens within a 12 second period since I can almost NEVER catch it with the NMAP scanning (which runs every 12 seconds).
I think the DASH buttons make EXCELLENT smart buttons for non time sensitive things like Good Morning
, & Good Night
scenes.
@CCOSTAN wow! I figured it took minutes at a time to time out.
Ok, used for the right thing, then it sounds like it'll totally work. Awesome.
Yup! Should be within 10 seconds, and if you resort to DNS hackery you can even redirect the address and run your own script. If you return 200 OK
it'll blink to confirm. That takes more effort though, so it might be optional.
Don't you need to run as root to listen for arp packets?
On Tue, Oct 6, 2015, 08:08 Aditya Vaidyam notifications@github.com wrote:
Yup! Should be within 10 seconds, and if you resort to DNS hackery you can even redirect the address and run your own script. If you return 200 OK it'll blink to confirm. That takes more effort though, so it might be optional.
— Reply to this email directly or view it on GitHub https://github.com/balloob/home-assistant/issues/484#issuecomment-145888069 .
If we can somehow think of a workable solution for the Dash buttons, I think that would be awesome. (Front Page Reddit stuff!) :) 5 dollar buttons just in time for Christmas lighting!
I think the only real solution would be to run a process next to HA that POST
s to it. Running HA as root isn't really a good idea or even acceptable, especially JUST for these buttons.
The root requirement arises from the use of raw sockets; if we can find a way around that, perhaps using BSD sockets as a layer, it might work. It needs to be evaluated for compatibility though.
To clarify, layer 2 (ethernet, wireless) and layer 3 (raw sockets) require root, while layer 4 (tcp/udp) doesn't. I'm not sure if ARP sniffing would work at layer 4 either.
If HA did end up using a separate process running alongside, We could ALSO use the ARP detection for additional presence detection of Phones (people).
@CCOSTAN that's a good point. It might not hurt having general ARP detection available. :+1: Though I don't know what it looks like to bring up 2 processes in the current stack.
I suppose it could be the main HA process, and an "escalator" process. If the user allows a component to access the "escalator" process, Python IPC could facilitate multiple components communicating to a counterpart in that process. It's a little convoluted, but VERY powerful, and depending on implementation details, should be secure.
I've found a version that doesn't use scapy below:
# Written by Bob Steinbeiser (https://medium.com/@xtalker)
rawSocket = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(0x0003))
while True:
packet = rawSocket.recvfrom(2048)
ethernet_header = packet[0][0:14]
ethernet_detailed = struct.unpack('!6s6s2s', ethernet_header)
arp_header = packet[0][14:42]
arp_detailed = struct.unpack('2s2s1s1s2s6s4s6s4s', arp_header)
# skip non-ARP packets
ethertype = ethernet_detailed[2]
if ethertype != '\x08\x06':
continue
source_mac = binascii.hexlify(arp_detailed[5])
dest_ip = socket.inet_ntoa(arp_detailed[8])
if source_mac == MAC:
# BUTTON 1 PRESSED
else if source_mac == OTHER_MAC:
# BUTTON 2 PRESSED
# and on and on, for as many buttons you need
Just use an ESP8266 and to make a Dash-like-button and have it trigger something in HA directely through REST API...
Easy to say, but the Dash is an easy to purchase button that literally does just that. It would be a bigger "attraction" to the HA platform if you told a person they could buy smart bulbs and a button to trigger things manually with it, along with the automation.
Essentially, a non-programmer/hardware person isn't going to want to fiddle with an ESP8266. It would be more beneficial if we could reroute the Dash itself to a REST API or something similar.
@sfam I agree with @avaidyam. Even with great instructions like this, http://deqingsun.github.io/ESP8266-Dash-Button/ , I'm still intimidated!
Or this one: https://www.hackster.io/noelportugal/ifttt-smart-button
of course an user-friendly solution would be ideal, but just wanted to show an alternative for those with courage to start hacking with esp8266... :D
I've just picked up a Dash button myself, and will now be able to take a look at the implementation details.
This would be the BEST ANSWER. Amazon may eventually sell hackable buttons that use the lambda service. That would solve everything.
http://hackaday.com/2015/10/11/amazon-giving-out-sort-of-hackable-amazon-dash-button/
Unfortunately, it doesn't seem like those are going to be available anytime soon. I'm looking into DNSMasq and router-level fencing to interface with the Dash. It may not really be worth it...
I wrote a service last week that lets you register your Dash button and map URLs to process whenever they've been pressed. It's pretty simple. The config looks like this:
{"buttons":[
{
"name": "Party Time",
"address": "a0:02:dc:d9:63:49",
"url": "http://media.local:8123/api/services/scene/turn_on",
"method": "POST",
"headers": {"x-ha-access": "XXX"},
"json": true,
"body": {"entity_id": "scene.party_time"}
},
{
"name": "Music",
"address": "74:75:48:36:45:29",
"url": "http://media.local:8123/api/services/media_player/media_play",
"method": "POST",
"headers": {"x-ha-access": "XXX"},
"json": true,
"body": {"entity_id": "media_player.itunes"}
}
]}
You would need to run this separately, but you can run just this as root. I'll post it up sometime soon.
I can't speak much to it's reliability as I haven't even figured out a good reason to use the buttons :grinning: so I haven't really used this outside of just getting it to work, heh.
I posted it - https://github.com/maddox/dasher
@maddox This is great. I think I am going to use it to post events to HA and then from HA, use the event to trigger and then based on conditions, execute various things. (Turn on things in the morning, turn off things at night kinda things)
@maddox Any thoughts on a python port, so HA can assimilate it?
Closing issue, seeing as root requirement for HA is a bad idea; use @maddox's tool instead.
According to @soggypretzels this is what comes up in google if you search for amazon dash and Home-Assistant. Some people seem to have problems with the dasher package. Just in case you can't get dasher to work, I have a python version that does the same thing. https://github.com/w1ll1am23/pydasher however, you should try to get Maddox's dasher working first I use it, and it works great.
I have some notes on this at http://somnambulistic-monkey.blogspot.com/2016/07/home-assistant-custom-events-and-amazon.html - I'm using an HA event/trigger where the name includes the Dash MAC address.
I used DNSmasq on my router to detect the Dash and then send the event via HA's REST api.
Using
scapy
and a quick ARP-hunting python script:it's possible to use an Amazon Dash button as a trigger. This would be super helpful, since now you have a cheap 5$ button that can toggle any lighting setup you want, for starters.
Is anyone already implementing such a feature?