Ricardo1980 / dasher-hue

Use your Amazon Dash buttons directly with Philips Hue to control your lights.
MIT License
10 stars 0 forks source link

dasher-hue

dasher-hue is a simple way to bridge your Amazon Dash buttons to Philips Hue lights. This small project is just a combination of two existing projects:

node-hue-api dasher

See it in action:

IMAGE ALT TEXT

How it works

Configure dasher-hue via config/config.json. You have to setup your Philips Hue (IP and username) and all the Amazon Dash Buttons you have.

Configuration

You define your buttons via the config/config.json file. You attach each button to a specific group or a specific light, what you prefer.

Here's an example.

{
  "philips_hue": {
    "ipaddress": "192.168.0.10",
    "username": "your-philips-hue-username-key"
  },
  "buttons":[
  {
    "name": "Amazon Dash Fiesta Living Room",
    "address": "50:50:50:50:50:51",
    "group": "1"
  },
  {
    "name": "Amazon Dash Rodial Bedroom",
    "address": "50:50:50:50:50:52",
    "group": "2"
  },
  {
    "name": "Amazon Dash ON Corridor",
    "address": "50:50:50:50:50:53",
    "light": "6"
  }
]}

Buttons take 4 options.

Amazon Dash Button tips.

Setup

In order to get your Amazon Dash Button mac address, get instructions and scripts from here

Check Setup section here

Set up dasher-hue.

git clone https://github.com/Ricardo1980/dasher-hue
cd dasher-hue
npm install

Then create a config.json in /config to set up your Dash buttons. Or use the the sample file, renaming it and modifying according to your needs.

Launching it

Listening for Amazon Dash Buttons requires root. So you need to start dasher-hue with sudo.

sudo npm run start

Auto Start on Raspberry Pi Zero (or other Linux distributions)

For creating and setting up a service, check this.

An example could be:

[Unit]
Description=dasher-hue

[Service]
ExecStart=/usr/local/bin/node /home/pi/dasher-hue/app.js
Restart=always
 # Restart service after 10 seconds if node service crashes
 RestartSec=10
 # Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=dasher-hue
Environment=NODE_ENV=production PORT=1337

[Install]
WantedBy=multi-user.target

In /etc/systemd/system/dasher-hue.service And then use

sudo systemctl enable dasher-hue.service
sudo systemctl start dasher-hue.service

Improvements

Locate Philips Hue Bridge automatically, rather than using an IP. Check: nupnpSearch(), locateBridges(), upnpSearch or searchForBridges()