Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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.

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; }
if [ -z $IP ]; then
# trying to figure the IP address myself
IP=`curl 2> /dev/null | jq -r ".[0].internalipaddress"`
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
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
echo $IP
curl -X PUT -d '{"touchlink":true}' http://$IP/api/$USERNAME/config

This comment has been minimized.

Copy link

@if-drew if-drew commented Dec 13, 2017

You need to wrap the $USERNAME variable in quotes. If line #18 returns '' then line #20 resolves to if [ == "null"]; then which throws an error.

More info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment