-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlightstate_button
More file actions
executable file
·49 lines (42 loc) · 1.97 KB
/
lightstate_button
File metadata and controls
executable file
·49 lines (42 loc) · 1.97 KB
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
#!/usr/bin/env bash
debug=false
hueBridge='duckwilliam.asuscomm.com' # Enter the IP address of your Philips Hue Bridge
huePort='8999' # Dont change unless you know what you're doing
hueApiHash='BojwEitzypKM4XP-BFNC3dtlukO-W8lmI-a1qMdh' # Enter your Hue API hash (s.a.)
hueBaseUrl="http://$hueBridge:$huePort/api/$hueApiHash" # Don't change
hueTimeOut='5' # Dont change unless you know what youre doing
while getopts :d: flag; do
case "$flag" in
d)
debug=${OPTARG}
;;
*)
:
;;
esac
done
#echo "debug = $debug"
if [[ $debug = true ]]; then
echo -e "\n---- DEBUG ----\n"
output_all=$(curl --silent --max-time 5 --request GET ${hueBaseUrl}/groups/6/)
echo -e "OUTPUT_ALL:\n$output_all\n"
output_grep_any_on_false=$(curl --silent --max-time 5 --request GET ${hueBaseUrl}/groups/6/ | grep -i 'any_on..false')
echo -e "OUTPUT_GREP (any_on=false):\n$output_grep_any_on_false"
output_grep_any_on_false_status=$(curl --silent --max-time 5 --request GET ${hueBaseUrl}/groups/6/ | grep -iq 'any_on..false'; echo "${PIPESTATUS[1]}")
echo -e "\tOUTPUT_GREP (any_on=false status):\t$output_grep_any_on_false_status\n"
output_grep_any_on_true=$(curl --silent --max-time 5 --request GET ${hueBaseUrl}/groups/6/ | grep -i 'any_on..true')
echo -e "OUTPUT_GREP (any_on=true):\n$output_grep_any_on_true"
output_grep_any_on_true_status=$(curl --silent --max-time 5 --request GET ${hueBaseUrl}/groups/6/ | grep -iq 'any_on..true'; echo "${PIPESTATUS[1]}")
echo -e "\tOUTPUT_GREP (any_on=true status):\t$output_grep_any_on_true_status"
echo -e "\n---- DEBUG END ----\n"
fi
status="$(curl --silent --max-time 5 --request GET ${hueBaseUrl}/groups/6/ | grep -qi 'any_on..false'; echo ${PIPESTATUS[1]})"
#echo -e "\nstatus = $status"
if [[ $status = 0 ]]; then
echo "off"
#echo "{PlasmoidIconStart}/usr/share/icons/HighContrast/48x48/apps/gnomine.png{PlasmoidIconEnd}"
else
echo "on"
#echo "{PlasmoidIconStart}/usr/share/icons/HighContrast/48x48/actions/action-unavailable.png{PlasmoidIconEnd}"
fi
##