lifx_dash 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ module LifxDash
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,66 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lifx_dash/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lifx_dash"
8
+ spec.version = LifxDash::VERSION
9
+ spec.authors = ["Matthew Hutchinson"]
10
+ spec.email = ["matt@hiddenloop.com"]
11
+
12
+ spec.summary = "Toggle LIFX lights with an Amazon Dash button"
13
+ spec.homepage = "http://github.com/matthutchinson/lifx_dash"
14
+ spec.license = "MIT"
15
+
16
+ spec.description = <<-EOF
17
+ A command line tool to listen for Amazon Dash button presses and toggle LIFX
18
+ lights ON and OFF (via the LIFX HTTP API). With options to configure: the Dash
19
+ MAC address, network interface and LIFX bulb selector. Inspired by Ted
20
+ Benson's hack (http://tinyurl.com/zba3da2). Root access is required for
21
+ network packet sniffing.
22
+ EOF
23
+
24
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the
25
+ # 'allowed_push_host' to allow pushing to a single host or delete this section
26
+ # to allow pushing to any host.
27
+ if spec.respond_to?(:metadata)
28
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
29
+ else
30
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
31
+ end
32
+
33
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|features)/}) }
34
+ spec.test_files = `git ls-files -- {test,features}/*`.split("\n")
35
+ spec.bindir = "bin"
36
+ spec.executables = "lifx_dash"
37
+ spec.require_paths = ["lib"]
38
+
39
+ # documentation
40
+ spec.has_rdoc = true
41
+ spec.extra_rdoc_files = ['README.md', 'LICENSE.txt']
42
+ spec.rdoc_options << '--title' << 'lifx_dash' << '--main' << 'README.md' << '-ri'
43
+
44
+ # non-gem dependecies
45
+ spec.required_ruby_version = ">= 2.0.0"
46
+ spec.requirements << 'an Amazon Dash button'
47
+ spec.requirements << 'one or more LIFX bulbs'
48
+ spec.requirements << 'root (sudo) access'
49
+
50
+ # external gems
51
+ spec.add_runtime_dependency "gli", "2.14.0"
52
+ spec.add_runtime_dependency "packetfu", "1.1.11"
53
+
54
+ # dev gems
55
+ spec.add_development_dependency "bundler"
56
+ spec.add_development_dependency "rake"
57
+ # docs
58
+ spec.add_development_dependency "ronn"
59
+ spec.add_development_dependency "rdoc"
60
+ # testing
61
+ spec.add_development_dependency "minitest"
62
+ spec.add_development_dependency "webmock"
63
+ spec.add_development_dependency "aruba"
64
+ spec.add_development_dependency "simplecov"
65
+ spec.add_development_dependency "coveralls"
66
+ end
@@ -0,0 +1,170 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "LIFX_DASH" "1" "June 2016" "" ""
5
+ .
6
+ .SH "NAME"
7
+ \fBlifx_dash\fR \- Toggle LIFX lights with an Amazon Dash button
8
+ .
9
+ .SH "SYNOPSIS"
10
+ \fBlifx_dash\fR \fBmonitor\fR \-m DASH_MAC_ADDRESS \-t LIFX_API_TOKEN
11
+ .
12
+ .br
13
+ \fBlifx_dash\fR \fBsnoop\fR
14
+ .
15
+ .br
16
+ \fBlifx_dash\fR \fBconfig\fR
17
+ .
18
+ .SH "DESCRIPTION"
19
+ \fBlifx_dash\fR is a simple command\-line tool to monitor your network for Amazon Dash button presses and toggle LIFX lights ON and OFF\. The tool provides two commands, \fBmonitor\fR and \fBsnoop\fR\.
20
+ .
21
+ .P
22
+ Use \fBsnoop\fR to listen for Dash presses on your network, and identify the button\'s MAC address\.
23
+ .
24
+ .P
25
+ Use \fBmonitor\fR (with a MAC address and LIFX HTTP API token) to respond to presses, and toggle your lights ON and OFF\. You can optionally pass a bulb selector, or choose to daemonize the \fBmonitor\fR process\.
26
+ .
27
+ .P
28
+ A \fBconfig\fR command also exists, allowing you to set default options for \fBmonitor\fR and \fBsnoop\fR\.
29
+ .
30
+ .SH "REQUIREMENTS"
31
+ \fBlifx_dash\fR requires at least one LIFX bulb, and any Amazon Dash button\. You will also need a wifi network and root access to sniff packets on your network adaptor\.
32
+ .
33
+ .P
34
+ Follow Amazon\'s Dash button setup steps, but \fBstop\fR before choosing any particular product to purchase\. You aill also need a free LIFX API token from here: \fIhttps://cloud\.lifx\.com/settings\fR
35
+ .
36
+ .SH "OPTIONS"
37
+ The snoop command has one optional flag, the network interface to listen on\.
38
+ .
39
+ .IP "\(bu" 4
40
+ \fB\-i\fR, \fB\-\-iface=arg\fR: Network Interface (default: en0)
41
+ .
42
+ .IP "" 0
43
+ .
44
+ .P
45
+ Wait for the network to quiet down, before pressing the button, since other devices may respond with ARP packets of their own when you press\. Take care to choose the MAC address from the ARP packet that occurs only once from a single MAC address\.
46
+ .
47
+ .P
48
+ The \fBmonitor\fR command accepts the following flags, both a mac address and api token are required\.
49
+ .
50
+ .IP "\(bu" 4
51
+ \fB\-m\fR, \fB\-\-mac\-address=arg\fR: Dash button MAC Address (required)
52
+ .
53
+ .IP "\(bu" 4
54
+ \fB\-t\fR, \fB\-\-token=arg\fR: LIFX HTTP API Token (required)
55
+ .
56
+ .IP "\(bu" 4
57
+ \fB\-s\fR, \fB\-\-selector=arg\fR: LIFX Bulb Selector (default: all)
58
+ .
59
+ .IP "\(bu" 4
60
+ \fB\-i\fR, \fB\-\-iface=arg\fR: Network Interface (default: en0)
61
+ .
62
+ .IP "\(bu" 4
63
+ \fB\-d\fR, \fB\-\-[no\-]daemonize\fR: Dameonize the monitor process (default: no)
64
+ .
65
+ .IP "\(bu" 4
66
+ \fB\-l\fR, \fB\-\-log\-file\fR: Log file location (when running as a daemon) (default: /tmp/lifx_dash\.log)
67
+ .
68
+ .IP "" 0
69
+ .
70
+ .SH "EXAMPLES"
71
+ Get help on command options and arguments
72
+ .
73
+ .IP "" 4
74
+ .
75
+ .nf
76
+
77
+ $ lifx_dash \-h
78
+ $ lifx_dash monitor \-h
79
+ $ lifx_dash snoop \-\-help
80
+ .
81
+ .fi
82
+ .
83
+ .IP "" 0
84
+ .
85
+ .P
86
+ Snoop for Dash button presses on en1
87
+ .
88
+ .IP "" 4
89
+ .
90
+ .nf
91
+
92
+ $ lifx_dash snoop en1
93
+ .
94
+ .fi
95
+ .
96
+ .IP "" 0
97
+ .
98
+ .P
99
+ Monitor Dash button presses on en0 with DASH_MAC_ADDRESS and LIFX_API_TOKEN, when pressed, toggle all lights
100
+ .
101
+ .IP "" 4
102
+ .
103
+ .nf
104
+
105
+ $ lifx_dash monitor \-t LIFX_API_TOKEN \-m DASH_MAC_ADDRESS
106
+ .
107
+ .fi
108
+ .
109
+ .IP "" 0
110
+ .
111
+ .P
112
+ Monitor Dash button presses on en1 with a DASH_MAC_ADDRESS and LIFX_API_TOKEN, when pressed toggle the light with id \'d3b2f2d97459\'
113
+ .
114
+ .IP "" 4
115
+ .
116
+ .nf
117
+
118
+ $ lifx_dash monitor \-\-token=LIFX_API_TOKEN \-\-mac\-address=DASH_MAC_ADDRESS \-s \'d3b2f2d97459\' \-i en1
119
+ .
120
+ .fi
121
+ .
122
+ .IP "" 0
123
+ .
124
+ .P
125
+ Show the current configuration file options
126
+ .
127
+ .IP "" 4
128
+ .
129
+ .nf
130
+
131
+ $ lifx_dash config \-s
132
+ .
133
+ .fi
134
+ .
135
+ .IP "" 0
136
+ .
137
+ .SH "FILES"
138
+ Use the \fBconfig\fR command to set values for the command options\. These will be saved to: ~/\.lifx_dash\.rc\.yml and used as defaults\. They can still be overridden by any arguments passed on the command line\.
139
+ .
140
+ .P
141
+ If running as a daemon (\-d switch), the \fBlifx_dash monitor\fR command will log to \fB/tmp/lifx_dash\.log\fR by default\. Use the \-\-log\-file flag to override this\.
142
+ .
143
+ .SH "BUGS"
144
+ No known bugs\. Please report issues here: \fIhttps://github\.com/matthutchinson/lifx_dash/issues\fR
145
+ .
146
+ .SH "LICENSE"
147
+ The MIT License: \fIhttps://raw\.githubusercontent\.com/matthutchinson/lifx_dash/master/LICENSE\.txt\fR
148
+ .
149
+ .SH "COPYRIGHT"
150
+ Copyright (c) 2016 Matthew Hutchinson
151
+ .
152
+ .SH "AUTHOR"
153
+ Matthew Hutchinson, \fIhttps://matthewhutchinson\.net\fR
154
+ .
155
+ .SH "SEE ALSO"
156
+ .
157
+ .IP "\(bu" 4
158
+ \fIhttps://rubygems\.org/gems/lifx_dash\fR
159
+ .
160
+ .IP "\(bu" 4
161
+ \fIhttps://github\.com/matthutchinson/lifx_dash\fR
162
+ .
163
+ .IP "\(bu" 4
164
+ \fIhttps://cloud\.lifx\.com/settings\fR
165
+ .
166
+ .IP "\(bu" 4
167
+ \fIhttp://tinyurl\.com/zujfkjs\fR
168
+ .
169
+ .IP "" 0
170
+
@@ -0,0 +1,217 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
+ <meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
6
+ <title>lifx_dash(1) - Toggle LIFX lights with an Amazon Dash button</title>
7
+ <style type='text/css' media='all'>
8
+ /* style: man */
9
+ body#manpage {margin:0}
10
+ .mp {max-width:100ex;padding:0 9ex 1ex 4ex}
11
+ .mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
12
+ .mp h2 {margin:10px 0 0 0}
13
+ .mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
14
+ .mp h3 {margin:0 0 0 4ex}
15
+ .mp dt {margin:0;clear:left}
16
+ .mp dt.flush {float:left;width:8ex}
17
+ .mp dd {margin:0 0 0 9ex}
18
+ .mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
19
+ .mp pre {margin-bottom:20px}
20
+ .mp pre+h2,.mp pre+h3 {margin-top:22px}
21
+ .mp h2+pre,.mp h3+pre {margin-top:5px}
22
+ .mp img {display:block;margin:auto}
23
+ .mp h1.man-title {display:none}
24
+ .mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
25
+ .mp h2 {font-size:16px;line-height:1.25}
26
+ .mp h1 {font-size:20px;line-height:2}
27
+ .mp {text-align:justify;background:#fff}
28
+ .mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
29
+ .mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
30
+ .mp u {text-decoration:underline}
31
+ .mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
32
+ .mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
33
+ .mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
34
+ .mp b.man-ref {font-weight:normal;color:#434241}
35
+ .mp pre {padding:0 4ex}
36
+ .mp pre code {font-weight:normal;color:#434241}
37
+ .mp h2+pre,h3+pre {padding-left:0}
38
+ ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
39
+ ol.man-decor {width:100%}
40
+ ol.man-decor li.tl {text-align:left}
41
+ ol.man-decor li.tc {text-align:center;letter-spacing:4px}
42
+ ol.man-decor li.tr {text-align:right;float:right}
43
+ </style>
44
+ </head>
45
+ <!--
46
+ The following styles are deprecated and will be removed at some point:
47
+ div#man, div#man ol.man, div#man ol.head, div#man ol.man.
48
+
49
+ The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
50
+ .man-navigation should be used instead.
51
+ -->
52
+ <body id='manpage'>
53
+ <div class='mp' id='man'>
54
+
55
+ <div class='man-navigation' style='display:none'>
56
+ <a href="#NAME">NAME</a>
57
+ <a href="#SYNOPSIS">SYNOPSIS</a>
58
+ <a href="#DESCRIPTION">DESCRIPTION</a>
59
+ <a href="#REQUIREMENTS">REQUIREMENTS</a>
60
+ <a href="#OPTIONS">OPTIONS</a>
61
+ <a href="#EXAMPLES">EXAMPLES</a>
62
+ <a href="#FILES">FILES</a>
63
+ <a href="#BUGS">BUGS</a>
64
+ <a href="#LICENSE">LICENSE</a>
65
+ <a href="#COPYRIGHT">COPYRIGHT</a>
66
+ <a href="#AUTHOR">AUTHOR</a>
67
+ <a href="#SEE-ALSO">SEE ALSO</a>
68
+ </div>
69
+
70
+ <ol class='man-decor man-head man head'>
71
+ <li class='tl'>lifx_dash(1)</li>
72
+ <li class='tc'></li>
73
+ <li class='tr'>lifx_dash(1)</li>
74
+ </ol>
75
+
76
+ <h2 id="NAME">NAME</h2>
77
+ <p class="man-name">
78
+ <code>lifx_dash</code> - <span class="man-whatis">Toggle LIFX lights with an Amazon Dash button</span>
79
+ </p>
80
+
81
+ <h2 id="SYNOPSIS">SYNOPSIS</h2>
82
+
83
+ <p><code>lifx_dash</code> <code>monitor</code> -m DASH_MAC_ADDRESS -t LIFX_API_TOKEN<br />
84
+ <code>lifx_dash</code> <code>snoop</code><br />
85
+ <code>lifx_dash</code> <code>config</code></p>
86
+
87
+ <h2 id="DESCRIPTION">DESCRIPTION</h2>
88
+
89
+ <p><strong>lifx_dash</strong> is a simple command-line tool to monitor your network for Amazon
90
+ Dash button presses and toggle LIFX lights ON and OFF. The tool provides two
91
+ commands, <code>monitor</code> and <code>snoop</code>.</p>
92
+
93
+ <p>Use <code>snoop</code> to listen for Dash presses on your network, and identify the
94
+ button's MAC address.</p>
95
+
96
+ <p>Use <code>monitor</code> (with a MAC address and LIFX HTTP API token) to respond to
97
+ presses, and toggle your lights ON and OFF. You can optionally pass a bulb
98
+ selector, or choose to daemonize the <code>monitor</code> process.</p>
99
+
100
+ <p>A <code>config</code> command also exists, allowing you to set default options for
101
+ <code>monitor</code> and <code>snoop</code>.</p>
102
+
103
+ <h2 id="REQUIREMENTS">REQUIREMENTS</h2>
104
+
105
+ <p><code>lifx_dash</code> requires at least one LIFX bulb, and any Amazon Dash button. You
106
+ will also need a wifi network and root access to sniff packets on your network
107
+ adaptor.</p>
108
+
109
+ <p>Follow Amazon's Dash button setup steps, but <strong>stop</strong> before choosing any
110
+ particular product to purchase. You aill also need a free LIFX API token from
111
+ here: <a href="https://cloud.lifx.com/settings" data-bare-link="true">https://cloud.lifx.com/settings</a></p>
112
+
113
+ <h2 id="OPTIONS">OPTIONS</h2>
114
+
115
+ <p>The snoop command has one optional flag, the network interface to listen on.</p>
116
+
117
+ <ul>
118
+ <li><code>-i</code>, <code>--iface=arg</code>: Network Interface (default: en0)</li>
119
+ </ul>
120
+
121
+
122
+ <p>Wait for the network to quiet down, before pressing the button, since other
123
+ devices may respond with ARP packets of their own when you press. Take care to
124
+ choose the MAC address from the ARP packet that occurs only once from a single
125
+ MAC address.</p>
126
+
127
+ <p>The <code>monitor</code> command accepts the following flags, both a mac address and api
128
+ token are required.</p>
129
+
130
+ <ul>
131
+ <li><code>-m</code>, <code>--mac-address=arg</code>: Dash button MAC Address (required)</li>
132
+ <li><code>-t</code>, <code>--token=arg</code>: LIFX HTTP API Token (required)</li>
133
+ <li><code>-s</code>, <code>--selector=arg</code>: LIFX Bulb Selector (default: all)</li>
134
+ <li><code>-i</code>, <code>--iface=arg</code>: Network Interface (default: en0)</li>
135
+ <li><code>-d</code>, <code>--[no-]daemonize</code>: Dameonize the monitor process (default: no)</li>
136
+ <li><code>-l</code>, <code>--log-file</code>: Log file location (when running as a daemon) (default: /tmp/lifx_dash.log)</li>
137
+ </ul>
138
+
139
+
140
+ <h2 id="EXAMPLES">EXAMPLES</h2>
141
+
142
+ <p>Get help on command options and arguments</p>
143
+
144
+ <pre><code>$ lifx_dash -h
145
+ $ lifx_dash monitor -h
146
+ $ lifx_dash snoop --help
147
+ </code></pre>
148
+
149
+ <p>Snoop for Dash button presses on en1</p>
150
+
151
+ <pre><code>$ lifx_dash snoop en1
152
+ </code></pre>
153
+
154
+ <p>Monitor Dash button presses on en0 with DASH_MAC_ADDRESS and LIFX_API_TOKEN,
155
+ when pressed, toggle all lights</p>
156
+
157
+ <pre><code>$ lifx_dash monitor -t LIFX_API_TOKEN -m DASH_MAC_ADDRESS
158
+ </code></pre>
159
+
160
+ <p>Monitor Dash button presses on en1 with a DASH_MAC_ADDRESS and LIFX_API_TOKEN,
161
+ when pressed toggle the light with id 'd3b2f2d97459'</p>
162
+
163
+ <pre><code>$ lifx_dash monitor --token=LIFX_API_TOKEN --mac-address=DASH_MAC_ADDRESS -s 'd3b2f2d97459' -i en1
164
+ </code></pre>
165
+
166
+ <p>Show the current configuration file options</p>
167
+
168
+ <pre><code>$ lifx_dash config -s
169
+ </code></pre>
170
+
171
+ <h2 id="FILES">FILES</h2>
172
+
173
+ <p>Use the <code>config</code> command to set values for the command options. These will be
174
+ saved to: ~/.lifx_dash.rc.yml and used as defaults. They can still be overridden
175
+ by any arguments passed on the command line.</p>
176
+
177
+ <p>If running as a daemon (-d switch), the <code>lifx_dash monitor</code> command will log to
178
+ <code>/tmp/lifx_dash.log</code> by default. Use the --log-file flag to override this.</p>
179
+
180
+ <h2 id="BUGS">BUGS</h2>
181
+
182
+ <p>No known bugs. Please report issues here:
183
+ <a href="https://github.com/matthutchinson/lifx_dash/issues" data-bare-link="true">https://github.com/matthutchinson/lifx_dash/issues</a></p>
184
+
185
+ <h2 id="LICENSE">LICENSE</h2>
186
+
187
+ <p>The MIT License:
188
+ <a href="https://raw.githubusercontent.com/matthutchinson/lifx_dash/master/LICENSE.txt" data-bare-link="true">https://raw.githubusercontent.com/matthutchinson/lifx_dash/master/LICENSE.txt</a></p>
189
+
190
+ <h2 id="COPYRIGHT">COPYRIGHT</h2>
191
+
192
+ <p>Copyright (c) 2016 Matthew Hutchinson</p>
193
+
194
+ <h2 id="AUTHOR">AUTHOR</h2>
195
+
196
+ <p>Matthew Hutchinson, <a href="https://matthewhutchinson.net" data-bare-link="true">https://matthewhutchinson.net</a></p>
197
+
198
+ <h2 id="SEE-ALSO">SEE ALSO</h2>
199
+
200
+ <ul>
201
+ <li><a href="https://rubygems.org/gems/lifx_dash" data-bare-link="true">https://rubygems.org/gems/lifx_dash</a></li>
202
+ <li><a href="https://github.com/matthutchinson/lifx_dash" data-bare-link="true">https://github.com/matthutchinson/lifx_dash</a></li>
203
+ <li><a href="https://cloud.lifx.com/settings" data-bare-link="true">https://cloud.lifx.com/settings</a></li>
204
+ <li><a href="http://tinyurl.com/zujfkjs" data-bare-link="true">http://tinyurl.com/zujfkjs</a></li>
205
+ </ul>
206
+
207
+
208
+
209
+ <ol class='man-decor man-foot man foot'>
210
+ <li class='tl'></li>
211
+ <li class='tc'>June 2016</li>
212
+ <li class='tr'>lifx_dash(1)</li>
213
+ </ol>
214
+
215
+ </div>
216
+ </body>
217
+ </html>