This repository has been archived by the owner on Nov 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdemo.sh
executable file
·96 lines (67 loc) · 2.17 KB
/
demo.sh
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# Demo for Hue BashLibrary (hue_bashlibrary.sh)
# Written 2013 by Markus Proske, released under GNU GENERAL PUBLIC LICENSE v2, see LICENSE
# Google+: https://plus.google.com/+MarkusProske
# Github: https://github.com/markusproske/hue_bashlibrary
# -----------------------------------------------------------------------------------------
# Note: this library relies on curl to be installed on your system.
# Type which curl or curl --help in your Terminal to see if it is installed
# If not, install with sudo apt-get install curl
# import my hue bash library
source hue_bashlibrary.sh
# CONFIGURATION
# -----------------------------------------------------------------------------------------
# Mind the gap: do not change the names of these variables, the bash_library needs those...
ip='10.0.1.8' # IP of hue bridge
devicetype='raspberry' # Link with bridge: type of device
username='huelibrary' # Link with bridge: username / app name
loglevel=1 # 0 all logging off, # 1 gossip, # 2 verbose, # 3 errors
# Variables of this scripts
lights='3 4' # Define the lights you want to use, e.g. '3' or '3 4' or '3 4 7 9'
# PROGRAM FUNCTIONS
# -----------------------------------------------------------------------------------------
function usage {
# cmdname is defined in the library
echo "Usage: $cmdname [link | unlink | discover | config]"
}
# MAIN
# -----------------------------------------------------------------------------------------
# store name of command for usage and log
# cmdname is defined in the library
cmdname=`basename "$0"`
# very simple argument processing
if [[ $# == 1 ]]
then
# valid number of arguments
if [[ $1 == "link" ]]
then
bridge_link
elif [[ $1 == "unlink" ]]
then
bridge_unlink
elif [[ $1 == "config" ]]
then
bridge_config
elif [[ $1 == "discover" ]]
then
bridge_discover
else
usage
fi
echo # force new line
exit
else
if (( $# > 1 ))
then
# more than one argument, show usage
usage
echo
exit
fi
fi
# no arguments
# demo mode, call function demo with the lights 3 and 4
hue_demo $lights
# hue_onoff "on" 3
# hue_is_on 3
# echo "Result variable is: $result_hue_is_on"