-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhue_white_mired_alter
executable file
·74 lines (59 loc) · 1.25 KB
/
hue_white_mired_alter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
[[ $1 == "--debug" ]] || [[ $1 == "-d" ]] && . hue_debug
. hue_settings
connection_test
val=326
already_send="no"
echo "makes color-temperature more warm(+) or cold(-) [+/-/q] :"
convert_send() {
w="$(printf '%04x' "${val}")"
c="0x"${w:0:2}
t="0x"${w:2}
echo ${val}
echo ${w}
echo $t", "$c
for lamp in ${array_lamps[@]}
do
dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_${lamp}/service0023/char002c org.bluez.GattCharacteristic1.WriteValue array:byte:"${t}, ${c}" dict:string:variant:
done
echo
}
while read -s -n 1 x
do
case $x in
+)
((val+=10))
if [[ $val -ge 500 ]]
then
val=500
echo -e "mired ${val} = maximum warm light\n"
[[ ${already_send} == "no" ]] && convert_send
already_send="yes"
else
convert_send
already_send="no"
fi
;;
-)
((val-=10))
if [[ $val -le 153 ]]
then
val=153
echo -e "mired ${val} = maximum cold light\n"
[[ ${already_send} == "no" ]] && convert_send
already_send="yes"
else
convert_send
already_send="no"
fi
;;
q)
echo -e "bye bye (;-)\n"
break
;;
*)
echo -e "please just use + or - or (q)uit.\n"
;;
esac
done
[[ $1 == "--debug" ]] || [[ $1 == "-d" ]] && characteristic_values