-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhue_set_bulb_name
executable file
·68 lines (56 loc) · 1.82 KB
/
hue_set_bulb_name
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
#!/bin/bash
################ TODO has to be altered using diferent number of bulbs!!!! #####################
[[ $1 == "--debug" ]] || [[ $1 == "-d" ]] && . hue_debug
. hue_settings
connection_test
read -p "Please input a individual name for a specific lamp: " lamp_name
lamp_name_hex=`printf "${lamp_name}" | od -A n -t x1 | sed "s/ /, 0x/g" | sed "s/^, //"`
while read -p "send to lamp: 1, 2, 3 or to (a)ll : " lamp
do
case "${lamp}" in
"1")
send_to_1="yes_send"
break
;;
"2")
send_to_2="yes_send"
break
;;
"3")
send_to_3="yes_send"
break
;;
"1 2"|"12")
send_to_1="yes_send"
send_to_2="yes_send"
break
;;
"2 3"|"23")
send_to_2="yes_send"
send_to_3="yes_send"
break
;;
"1 3"|"13")
send_to_1="yes_send"
send_to_3="yes_send"
break
;;
"all"|"a"|"123"|"1 2 3")
send_to_1="yes_send"
send_to_2="yes_send"
send_to_3="yes_send"
break
;;
*)
echo "For the Moment there are lamps 1, 2, 3 or (a)ll."
continue
;;
esac
done
echo
echo ${lamp_name_hex}
echo
[[ "$send_to_1" == "yes_send" ]] && dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_${lamp_kitchen}/service0011/char0014 org.bluez.GattCharacteristic1.WriteValue array:byte:"${lamp_name_hex}" dict:string:variant:
[[ "$send_to_2" == "yes_send" ]] && dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_${lamp_livingroom}/service0011/char0014 org.bluez.GattCharacteristic1.WriteValue array:byte:"${lamp_name_hex}" dict:string:variant:
[[ "$send_to_3" == "yes_send" ]] && dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_${lamp_homeoffice}/service0011/char0014 org.bluez.GattCharacteristic1.WriteValue array:byte:"${lamp_name_hex}" dict:string:variant:
[[ $1 == "--debug" ]] || [[ $1 == "-d" ]] && characteristic_values