Skip to content

Commit

Permalink
Merge pull request #25 from emericklaw/master
Browse files Browse the repository at this point in the history
Added configurable timeout delay
  • Loading branch information
danimtb authored Feb 21, 2018
2 parents 6c89aee + 17bd925 commit 34ed511
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Description: How dasshio works

This is a python script used to scan wifi devices connected to your network (using ARP and UDP). If a device matches any MAC address of the options, it will perform a HTTP POST request to the Home Assistant API.
This is a python script used to scan Wi-Fi devices connected to your network (using ARP and UDP). If a device matches any MAC address of the options, it will perform a HTTP POST request to the Home Assistant API.

## Usage

Expand Down Expand Up @@ -35,7 +35,7 @@ Here it is an example of a Dash Gillette button used to toggle a light and a Das

- name: name of your device
- address: MAC of your device
- domain: Home Assisntant domain (`light`, `switch`, `script`, `automation`...). Check [Home Assistant RESTful API](https://home-assistant.io/developers/rest_api/).
- domain: Home Assistant domain (`light`, `switch`, `script`, `automation`...). Check [Home Assistant RESTful API](https://home-assistant.io/developers/rest_api/).
- service: Home Assistant service.
- service_data: Home Assistant service data to call the service (Optional).

Expand All @@ -54,7 +54,7 @@ Here it is an example of a Dash Gillette button used to toggle a light and a Das
{
"name": "Bounty",
"address": "AC:63:BE:77:C4:0C",
"domain": "script"
"domain": "script",
"service": "welcome_home",
"service_data": "{}"
}]
Expand All @@ -67,7 +67,7 @@ Here it is an example of a Dash Gillette button used to toggle a light and a Das

## Options: url, body, headers

Another possiblity would be to use Dasshio to perform a HTTP Post request to an URL outside Home Assistant. To do so you can use the configuration below.
Another possibility would be to use Dasshio to perform a HTTP Post request to an URL outside Home Assistant. To do so you can use the configuration below.

- name: name of your device
- address: MAC of your device
Expand Down Expand Up @@ -99,11 +99,15 @@ Another possiblity would be to use Dasshio to perform a HTTP Post request to an

**Note**: As described above, you can still use `http://hassio/homeassistant/api` to route requests over the Hassio local network and perform API calls to Home Assistant. You can see [Hass.io Addon Communication](https://home-assistant.io/developers/hassio/addon_communication/#home-assistant) for more information.

## Options: timeout

By default Dasshio waits 20 seconds after a button press before resuming, this is to avoid detecting duplicate button presses. This option allows you to change this delay, if you want more responsive buttons then decrease this value and increase it if you experience duplicate presses.

## How to find the MAC address of your Dash

At the moment, the best way to do this is to hold down the button for 6 seconds, disconnect from the current WIFI and connect to the *Amazon ConfigureMe* SSID. If prompted, "stay connected" and open web page **192.168.0.1**. You will see your button’s ‘about’ page with the MAC and the additional information.
At the moment, the best way to do this is to hold down the button for 6 seconds, disconnect from the current Wi-Fi and connect to the *Amazon ConfigureMe* SSID. If prompted, "stay connected" and open web page **192.168.0.1**. You will see your button’s ‘about’ page with the MAC and the additional information.

Alternatively, you can access your Wifi Router and check the MAC addresses in the history of connected devices. Then, copy and paste the MAC in a service like [MA:CV:en:do:rs](https://macvendors.com/) to find the Vendor of that device. The Amazon Dash button vendor should be: *Amazon Technologies Inc.*
Alternatively, you can access your Wi-Fi Router and check the MAC addresses in the history of connected devices. Then, copy and paste the MAC in a service like [MA:CV:en:do:rs](https://macvendors.com/) to find the Vendor of that device. The Amazon Dash button vendor should be: *Amazon Technologies Inc.*

---------------------

Expand Down
6 changes: 4 additions & 2 deletions dasshio/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Dasshio",
"version": "0.2.0",
"version": "0.2.1",
"slug": "dasshio",
"description": "Use Amazon Dash Buttons in Home Assistant",
"url": "https://github.com/danimtb/dasshio",
Expand All @@ -9,6 +9,7 @@
"host_network": "True",
"homeassistant_api": "True",
"options": {
"timeout": 20,
"buttons": [
{
"name": "null",
Expand All @@ -20,6 +21,7 @@
]
},
"schema": {
"timeout": "int",
"buttons": [
{
"name": "str",
Expand All @@ -33,4 +35,4 @@
}
]
}
}
}
5 changes: 3 additions & 2 deletions dasshio/dasshio.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,6 @@ def arp_display(pkt):
logging.info("Starting sniffing...")
sniff(stop_filter=arp_display,
filter="arp or (udp and src port 68 and dst port 67 and src host 0.0.0.0)", store=0, count=0)
logging.info("Packet captured, waiting 20s ...")
time.sleep(20)
timeout = config["timeout"]
logging.info("Packet captured, waiting " + str(timeout) + "s ...")
time.sleep(timeout)

0 comments on commit 34ed511

Please sign in to comment.