nlhue 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .ruby-version
11
+ .ruby-gemset
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nlhue.gemspec
4
+ gemspec
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here