Skip to content
This repository has been archived by the owner on Apr 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request fxbox#108 from fxbox/cr-huedemo
Browse files Browse the repository at this point in the history
Output format improvements for huedemo.sh script
  • Loading branch information
fabricedesre committed Mar 1, 2016
2 parents 394ebc0 + 23aefb0 commit a061a9e
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions huedemo.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
#!/bin/bash

HOST="localhost:3000"
VAL=0.2


huecmd() {
id=$1
cmd=$2
echo -n "$cmd -> "
curl -s -X PUT "http://$HOST/services/$id/state" -d "$cmd"
echo
}

cmd=$1

case $cmd in
status)
echo "Talking to FoxBox at http://$HOST/services"
curl -s -X GET http://localhost:3000/services/list.json \
| tr '{' \\012 \
| cut -d, -f1 \
Expand All @@ -17,23 +30,22 @@ case $cmd in
done
;;
disco)
echo "Talking to FoxBox at http://$HOST/services"
id=$2
curl -s -X PUT http://localhost:3000/services/$id/state -d '{"on": true}'
echo
huecmd $id '{"on": true}'
while true ; do
curl -s -X PUT http://localhost:3000/services/$id/state -d '{"hue": 0.0, "sat": 1.0, "val": 1}'
echo
huecmd $id '{"hue": 0.0, "sat": 1.0, "val": '$VAL'}'
sleep 2
curl -s -X PUT http://localhost:3000/services/$id/state -d '{"hue": 120, "sat": 1.0, "val": 1}'
echo
huecmd $id '{"hue": 120, "sat": 1.0, "val": '$VAL'}'
sleep 2
curl -s -X PUT http://localhost:3000/services/$id/state -d '{"hue": 240, "sat": 1.0, "val": 1}'
echo
huecmd $id '{"hue": 240, "sat": 1.0, "val": '$VAL'}'
sleep 2
done
;;
off)
curl -s -X PUT http://localhost:3000/services/$2/state -d '{"on": false}'
echo "Talking to FoxBox at http://$HOST/services"
id=$2
huecmd $id '{"on": false}'
;;
*)
echo "usage: $0 <cmd> [<id>]"
Expand All @@ -42,4 +54,3 @@ case $cmd in
echo " off <id> - turn off the lights!"
esac


0 comments on commit a061a9e

Please sign in to comment.