npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pimatic-amazing-dash-button

v0.9.15

Published

Pimatic plugin for Amazon's dash-buttons

Downloads

66

Readme

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