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.
Created
October 24, 2015 17:23
-
-
Save trieloff/76c7c24ecff7d694602d to your computer and use it in GitHub Desktop.
A command line alternative to LampStealer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
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 https://stackoverflow.com/a/15573770