nlhue 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +91 -0
- data/Rakefile +1 -0
- data/bin/console +12 -0
- data/bin/setup +7 -0
- data/lib/nlhue/bridge.rb +830 -0
- data/lib/nlhue/disco.rb +362 -0
- data/lib/nlhue/group.rb +79 -0
- data/lib/nlhue/light.rb +20 -0
- data/lib/nlhue/request_queue.rb +131 -0
- data/lib/nlhue/scene.rb +88 -0
- data/lib/nlhue/ssdp.rb +106 -0
- data/lib/nlhue/target.rb +411 -0
- data/lib/nlhue/version.rb +3 -0
- data/lib/nlhue.rb +36 -0
- data/nlhue.gemspec +28 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3feebc5e72316132ee5ad26feef1b4796c6f5567
|
4
|
+
data.tar.gz: 18a322dc0c0964268450142f995e22c36d836574
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dd0d71faacb9941e8dd2be87ebb515b3ce8842a623864bf210f92c9cbf0cc0399c175f2a31d3320e3b87d0c74aeb38b27f287e3184a09ea347d7a89a51256105
|
7
|
+
data.tar.gz: fba985b9eb5facfd853f4eec98fe3b51f06f72f562006712a6a72549d009381411a9b84549f0a4ee19d86808b370e0a5a1cdbb06eade3a29f5f66dbb2b3ec7c9
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016, Mike Bourgeous and Nitrogen Logic
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
14
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
15
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
17
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
18
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
19
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
20
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
21
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
22
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# NLHue
|
2
|
+
## An EventMachine-based Ruby library for interfacing with the Philips Hue lighting system.
|
3
|
+
|
4
|
+
©2012-2016 Mike Bourgeous, Nitrogen Logic
|
5
|
+
|
6
|
+
This Gem was created because in 2012 many of the other fine Ruby Hue libraries
|
7
|
+
lacked a clear license agreement, were only partially implemented, and/or
|
8
|
+
required far too many third-party Gems for my use.
|
9
|
+
|
10
|
+
NLHue uses an asynchronous callback-based API built on EventMachine. It's not
|
11
|
+
exactly easy to use, and not recommended for non-EventMachine-based
|
12
|
+
applications.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'nlhue'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install nlhue
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
TODO: Write usage instructions here
|
33
|
+
|
34
|
+
## Useful info
|
35
|
+
|
36
|
+
### Working with Hue using cURL
|
37
|
+
|
38
|
+
Useful command-line stuff:
|
39
|
+
|
40
|
+
```bash
|
41
|
+
HUE_IP=[x.x.x.x]
|
42
|
+
HUE_KEY=[hue_api_key]
|
43
|
+
alias off='curl -X PUT -d '\''{"on":false}'\'' http://${HUE_IP}/api/${HUE_KEY}/lights/2/state ; echo'
|
44
|
+
alias on='curl -X PUT -d '\''{"on":true}'\'' http://${HUE_IP}/api/${HUE_KEY}/lights/2/state ; echo'
|
45
|
+
alias pink='curl -X PUT -d '\''{"hue":58000,"sat":254,"bri":254,"transitiontime":0}'\'' http://${HUE_IP}/api/${HUE_KEY}/lights/2/state ; echo'
|
46
|
+
alias purple='curl -X PUT -d '\''{"hue":48400,"sat":254,"bri":254,"transitiontime":0}'\'' http://${HUE_IP}/api/${HUE_KEY}/lights/2/state ; echo'
|
47
|
+
alias red='curl -X PUT -d '\''{"hue":0,"sat":254,"bri":254,"transitiontime":0}'\'' http://${HUE_IP}/api/${HUE_KEY}/lights/2/state ; echo'
|
48
|
+
alias green='curl -X PUT -d '\''{"hue":21844,"sat":254,"bri":254,"transitiontime":0}'\'' http://${HUE_IP}/api/${HUE_KEY}/lights/2/state ; echo'
|
49
|
+
alias blue='curl -X PUT -d '\''{"hue":46774,"sat":254,"bri":254,"transitiontime":0}'\'' http://${HUE_IP}/api/${HUE_KEY}/lights/2/state ; echo'
|
50
|
+
hue() { M="{\"hue\":$(($1 * 182)),\"sat\":254,\"bri\":254,\"transitiontime\":10}" ; curl -X PUT -d "$M" http://${HUE_IP}/api/${HUE_KEY}/lights/2/state; echo; }
|
51
|
+
```
|
52
|
+
|
53
|
+
### Notes on Hue scenes
|
54
|
+
|
55
|
+
> Recalling a scene with curl (always posted to group 0):
|
56
|
+
>
|
57
|
+
> ```bash
|
58
|
+
> curl -X PUT http://[ip]/api/[key]/groups/0/action --data-binary '{"scene":"4170a6910-on-0"}'
|
59
|
+
> ```
|
60
|
+
>
|
61
|
+
> It seems like scenes with "fon" in the name (or any number other than 0 after
|
62
|
+
> -on-) should be ignored.
|
63
|
+
>
|
64
|
+
> If multiple scenes of the same name exist ending in -on-0 or -off-0, choose the
|
65
|
+
> one with the highest timestamp? It's possible that only the Hue app creates
|
66
|
+
> timestamps, so don't assume they will be there.
|
67
|
+
>
|
68
|
+
> Typical scene ID from Hue app: "xxxxxxxxx-on-0"
|
69
|
+
> Typical scene name from app: "Scene Name (on|off|fon) [timestamp]"
|
70
|
+
>
|
71
|
+
> Sometimes the timestamp is abbreviated to 5 digits, but it's typically the
|
72
|
+
> number of milliseconds since 1970-01-01.
|
73
|
+
>
|
74
|
+
> --
|
75
|
+
>
|
76
|
+
> After further investigation it looks like the "-on-2"/"-on-4" scenes are fade
|
77
|
+
> in times of 2 and 4 minutes, and the "fon" in the middle of a scene name means
|
78
|
+
> "fade on". The transitiontime parameter doesn't work when recalling a scene.
|
79
|
+
> The transition time is saved with the scene.
|
80
|
+
>
|
81
|
+
> See http://www.everyhue.com/vanilla/discussion/1124/scenes-api
|
82
|
+
>
|
83
|
+
> --
|
84
|
+
>
|
85
|
+
> *Recalling a scene on a group other than 0 seems to limit the scene's effects to
|
86
|
+
> the lights in that group.*
|
87
|
+
|
88
|
+
|
89
|
+
## License
|
90
|
+
|
91
|
+
NLHue is licensed under the two-clause BSD license.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "nlhue"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require 'pry'
|
11
|
+
require 'pry-byebug'
|
12
|
+
Pry.start
|