Skip to content

Instantly share code, notes, and snippets.

@philmtd
Forked from trieloff/README.md
Created December 12, 2017 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philmtd/da89a31b681f82be0e1abe3cb89cde96 to your computer and use it in GitHub Desktop.
Save philmtd/da89a31b681f82be0e1abe3cb89cde96 to your computer and use it in GitHub Desktop.
A command line alternative to LampStealer

The LampStealer app for Hue does not work with newer versions of the bridge, as the API has changed. This shell script works with fewer dependencies and achieves the same. Install jq and run the shell script after pushing the big button on the bridge.

#!/bin/sh
curl --help >/dev/null 2>&1 || { echo >&2 "I require curl but it's not installed. Aborting."; exit 1; }
jq --version >/dev/null 2>&1 || { echo >&2 "I require jq but it's not installed. Aborting."; exit 1; }
IP=$@
if [ -z $IP ]; then
# trying to figure the IP address myself
IP=`curl https://www.meethue.com/api/nupnp 2> /dev/null | jq -r ".[0].internalipaddress"`
fi
if [ -z $IP ]; then
echo "Call this script with the IP address of your Hue bridge. You can find it in the iPhone app"
exit 1
fi
USERNAME=`curl -X POST -d '{"devicetype": "HueLights#API"}' http://$IP/api 2> /dev/null | jq -r ".[0].success.username"`
if [ $USERNAME == "null" ]; then
echo "Could not get a username. Press the big button on the bridge before running this script."
exit 2
fi
echo $IP
echo $USERNAME
curl -X PUT -d '{"touchlink":true}' http://$IP/api/$USERNAME/config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment