另一个 shell 脚本,具有通过 HSB 和转换时间设置颜色的有用功能。
#!/bin/sh
#
# Register "patniemeyer" key with this bridge
#
# % curl -d '{"username": "patniemeyer", "devicetype": "Philips hue"}' http://192.168.1.179/api
# [{"success":{"username":"patniemeyer"}}]
#
KEY='patniemeyer'
IP='192.168.1.179'
#
# Light number, hue, saturation, brightness, transition time
#
# hue 0-65535
# sat 0-255?
# transition time 1/10 seconds
#
lightNHSBT()
{
_lightNum=$1
_hue=$2
_sat=$3
_brightness=$4
_ttime=$5
curl --request PUT --data "{\"hue\":$_hue, \"sat\":$_sat, \"bri\":$_brightness, \"on\":true, \"transitiontime\":$_ttime}" http://$IP/api/$KEY/lights/$_lightNum/state/
}
#
# CIE 1931 X,Y colors
# Light number, X, Y, brightness, transition time
#
# transition time 1/10 seconds
#
lightNXYBT()
{
_lightNum=$1
_x=$2
_y=$3
_brightness=$4
_ttime=$5
curl --request PUT --data "{\"xy\":[$_x,$_y], \"bri\":$_brightness, \"on\":true, \"transitiontime\":$_ttime}" http://$IP/api/$KEY/lights/$_lightNum/state/
}
#
for f in 1 2 3 4 5 6
do
lightNHSBT $f 0 255 255 5 # full red
done