Publish dash button presses to a MQTT broker. 🔘📡
Tested on macOS and Linux. If you're running on Linux you have to install libpcap-dev:
$ sudo apt-get install libpcap-dev
$ sudo yum install libpcap-devel
Prerequisite: Node.js version 6.0 or above. I suggest to use https://github.com/tj/n to install a recent version of Node.js.
$ sudo npm install -g dashbutton2mqtt
$ sudo dashbutton2mqtt --scan
The scan shows only MAC Addresses that are known to be registered by Amazon. If you want to see all detected addresses
add the option
Create a JSON file that maps dash button mac addresses to MQTT topics and payloads.
If you omit the payload attribute an empty string will be published.
$ sudo dashbutton2mqtt -m /path/to/mapping.json
By default this tool binds to the first network interface. To bind to a specific interface, such as eth6, pass the name
of the interface with the
If multiple presses are detected you can increase the timeout between presses. Default is 5000ms, depending on your
network this may not be enough, you can set a higher timeout with the
Usage: dashbutton2mqtt [options] Options: -v, --verbosity possible values: "error", "warn", "info", "debug" [default: "info"] -s, --scan scan for dash buttons -m, --mapping json file containing dashbutton-mqtt mappings (see Readme) [default: "/Users/basti/WebstormProjects/dashbutton2mqtt/example.json"] -n, --name instance name. used as mqtt client id and as prefix for connection topic [default: "dashbutton"] -u, --url mqtt broker url. See https://github.com/mqttjs/MQTT.js#connect-using-a-url [default: "mqtt://127.0.0.1"] -i, --interface bind to network interface to listen for dash button presses [default: null] -p, --protocol protocol to use for button detection. possible values: "arp", "udp", "all" [default: "all"] -t, --timeout timeout between button presses. [default: 5000] -h, --help Show help [boolean] --version Show version number [boolean]
I suggest PM2 to run dashbutton2mqtt in the background and start on system boot.
Pull requests welcome! 😀
MIT © Sebastian Raff