Code Monkey home page Code Monkey logo

pimatic-amazing-dash-button's Introduction

Amazing Dash-Button

pimatic-amazing-dash-button

Npm Version Build Status Dependency Status

A pimatic plugin for Amazon's dash-buttons. It is a pretty light-weight implementation which uses a ContactSensor or ButtonsDevice device abstraction for the dash-button. Auto-discovery of dash-buttons is supported.

The plugin sniffs for ARP probes which will be sent out by a dash-button when the button is pressed. The plugin is based on cap, a cross-platform libpcap binding for performing packet capturing with node.js. It can be used on *nix and Windows systems.

Contributions

If you like this plugin, please consider ★ starring the project on github. Contributions to the project are welcome. You can simply fork the project and create a pull request with your contribution to start with.

Stickers and Donations

Happy with pimatic and using it everyday? If you like to obtain one of these amazing dash-button stickers, please consider a donation to support the pimatic development and the operation of the website and user forum.

Installation

This plugin requires libpcap to capture ARP requests on the network. Moreover, it is required to have python v2.7 installed.

On Raspberry PI and comparable systems libpcap must be installed, i.e. sudo apt-get install libpcap-dev. On Windows, WinPcap must be installed. As the installation procedure uses node-gyp you will also need to have python v2.7 installed. Note, python v3 is not supported! See node-gyp installation notes for details.

Dash-Button Installation

Follow the instructions given in the Amazon Mobile App, to pair the dash-button with your WiFi network. However, don't select a product as requested in the last configuration step. Now, when the dash-button is pressed, the indicator LED of the dash-button should blink white for about three seconds. Following this, the LED will turn to solid red for a few seconds and might blink red (depending on the type of dash-button you have, apparently there are different makes). This indicates the device is not setup as there is no product setup, but this does not matter.

As an additional line of defense you may consider restricting internet access for the device as part of your router configuration.

Plugin Configuration

The "interfaceAddress" property may be omitted if your system only has a single network interface or the interface to choose is the first one on the list returned by the ifconfig command on the host. If the device discovery or the interaction with dash-button does not work as expected, provide the IP address associated with the network interface which shall be used to listen to ARP requests needs to be set.

{
      "plugin": "amazing-dash-button",
      "interfaceAddress": "192.168.1.15",
}

The plugin has the following configuration properties:

Property Default Type Description
interfaceAddress - String IP address associated with the network interface which shall be used to listen to ARP requests (optional)
ignoreMacAddresses - Array MAC addresses of candidate devices which shall be ignored. Typically, this is used to exclude other Amazon devices like Fire Tablet PCs.

Device Configuration

As of pimatic v0.9, dash-button devices can be automatically discovered. Simply open the "Devices" view of the pimatic web frontend and click on "Discover Devices". When the discovery has started, press the dash-button and the device should show up as a discovered device in pimatic after a few seconds.

You can also add the device manually by adding it to the "devices" section of the configuration or by creating the device using the device editor.

{
      "id": "AmazingDashButton1",
      "name": "AmazingDashButton1",
      "class": "AmazingDashButton",
      "macAddress": "ac:63:be:b3:be:78"
}

The device has the following configuration properties:

Property Default Type Description
macAddress - String MAC address of the device
invert false String If true, invert the contact state, i.e., contact is 'closed' if dash-button not pressed
holdTime 1500 Integer The number of milliseconds the contact shall enter the state indicating button pressed (closed if not inverted)

You can also use your dash-button device as DashButtonDevice. This device type will act like a ButtonsDevice with one button. The configuration is

 {
       "id": "DashButtonDevice1",
       "name": "DashButtonDevice1",
       "class": "DashButtonDevice",
       "macAddress": "ac:63:be:b3:be:78"
 }

The DashButtonDevice only supports the macAddress property.

When using the automatic discovery mode, just change the class to DashButtonDevice and copy the macAddress property.

Trigger Another Device

The AmazingDashButton is derived from ContactSensor and provides the following predicate: {device} is opened|closed. For example, if you wish to toggle a PowerSwitch device when the dash-button is pressed you can create a rule as follows:

when AmazingDashButton1 is closed then toggle {PowerSwitch Device}

For the DashButtonDevice the predicate is {device} is pressed, so this would lead to this rule:

when DashButtonDevice1 is pressed then toggle {PowerSwitch Device}

Trigger Action

It is also possible to trigger an AmazingDashButton device using the pimatic REST or WebSocket API as shown in the example below for a given device with id dash-1. Calling the device action will close the contact for the holdTime configured set as part of device configuration.

curl --user "username:password" /api/device/dash-1/trigger

For a DashButtonDevice this would be:

curl --user "username:password" /api/device/dash-1/buttonPressed?buttonId=dash-1

Trouble Shooting

  • "TypeError: Buffer.alloc is not a function" during installation

    Make sure, you have node version 4.5 or greater installed.

History

See Release History.

License

Copyright (c) 2016-2019, Marcus Wittig and contributors. All rights reserved.

AGPL-3.0

pimatic-amazing-dash-button's People

Contributors

greenkeeper[bot] avatar michbeck100 avatar mwittig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

kumart4

pimatic-amazing-dash-button's Issues

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Trial pre-filtering

Let libpcap filter for ARP request with src MAC containing one of Amazon's vendor ids.

Something like "arp && (eth.src[0:3] == 1C:5A:3E || eth.src[0:3] == BC:05:43)"

discover filter

please add a MAC discovery filter with "AC:63:BE:". at the moment my fire hd with "A0:02:DC:" would be detected as dash :D

Dash button device closes twice when dash button is pressed once

Amazin-Dash-Button: 0.9.12
Pimatic: 0.9.40

I've added a new dash button that I received just a few day ago from the German Amazon store:
image

When I click the dash button, it closes twice and hence triggers my corresponding rule twice.
dash_button_closed_twice

This does not happen with my two other dash buttons, that I acquired in the US roughly a year ago.

installing plugin error

458 info install [email protected]
459 verbose unsafe-perm in lifecycle true
460 info [email protected] Failed to exec install script
461 verbose unlock done using /opt/pimatic-app/.npm/_locks/cap-5f526ab8aca0e2d9.lock for /opt/pimatic-app/node_modules/pimatic-amazing-dash-button/node_modules/cap
462 verbose about to build /opt/pimatic-app/node_modules/pimatic-amazing-dash-button
463 verbose unlock done using /opt/pimatic-app/.npm/_locks/pimatic-amazing-dash-but-52828f536dd868cb.lock for /opt/pimatic-app/node_modules/pimatic-amazing-dash-button
464 verbose stack Error: [email protected] install: node-gyp rebuild
464 verbose stack Exit status 1
464 verbose stack at EventEmitter. (/opt/pimatic-app/node_modules/pimatic/node_modules/npm/lib/utils/lifecycle.js:217:16)
464 verbose stack at emitTwo (events.js:87:13)
464 verbose stack at EventEmitter.emit (events.js:172:7)
464 verbose stack at ChildProcess. (/opt/pimatic-app/node_modules/pimatic/node_modules/npm/lib/utils/spawn.js:24:14)
464 verbose stack at emitTwo (events.js:87:13)
464 verbose stack at ChildProcess.emit (events.js:172:7)
464 verbose stack at maybeClose (internal/child_process.js:854:16)
464 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:222:5)
465 verbose pkgid [email protected]
466 verbose cwd /opt/pimatic-app
467 error Linux 4.4.59+
468 error argv "/usr/local/bin/node" "/opt/pimatic-app/node_modules/pimatic/ppm.js" "install" "[email protected]" "--unsafe-perm"
469 error node v4.6.2
470 error npm v2.15.12
471 error code ELIFECYCLE
472 error [email protected] install: node-gyp rebuild
472 error Exit status 1
473 error Failed at the [email protected] install script 'node-gyp rebuild'.
473 error This is most likely a problem with the cap package,
473 error not with npm itself.
473 error Tell the author that this fails on your system:
473 error node-gyp rebuild
473 error You can get information on how to open an issue for this project with:
473 error npm bugs cap
473 error Or if that isn't available, you can get their info via:
473 error
473 error npm owner ls cap
473 error There is likely additional logging output above.

Button not working with Fritz!Repeater

I've set up the pimatic-amazing-dash and everything worked out fine. Because of the bad wlan range of the fritzbox6490, i've set up a range extender (fritz! as well), which is now nearer to the pimatic dash as the router itself.
If i press the button now - nothing happens. I think the problem is, that a) the dash button does recognise, that the repeater is another device or b) the dash connects through the repeater, but isn't recognised anymore by the pimatic-plugin. If i unplug the repeater, everything works out.

Amazon Fire HD 8 loged like a Dash Button

Hello,

today I saw in pimatic-daemon.log the IP and MAC Address from my Amazon Fire HD 8. This is the last enrty in my log, after this event the webinterface didn't reachable from my network. Rules didn't performed.

Pimatic-daemon.log:
21:02:10.957 [pimatic] info: rule dummyswitch-off-variable-0: set $beregnung_aktiv to 0 21:02:10.970 [pimatic] info: rule variable-0-beregnung-off: Pumpe Beregnung ausgeschaltet 21:02:10.975 [pimatic] info: rule variable-0-beregnung-off: Ventil Unten ausgeschaltet 21:02:12.957 [pimatic] info: rule variable-0-beregnung-off: Ventil Oben ausgeschaltet 21:03:09.893 [pimatic] info: rule beregnung-2-dev-2: Ventil Unten ausgeschaltet 21:04:09.700 [pimatic-amazing-dash-button] debug: [Plugin] ARP { mac: 'fc:65:de:fa:0b:09', ip: '192.168.192.123' } 21:04:10.678 [pimatic-amazing-dash-button] debug: [Plugin] ARP { mac: 'fc:65:de:fa:0b:09', ip: '192.168.192.123' } 06:36:07.298 2018-04-03 Tuesday

MAC Address and IP are from my Amazon Fire HD 8.
When i blocked the MAC Address in router the message didn't appeared anymore.
But i cannot use the Fire HD in network. Make sense. :D

With my Raspberry Pi 2 i didn't have problems like that, after a change to Raspberry Pi 3+ and Raspbian Stretch Lite i had many issues.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.