nlhue 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3feebc5e72316132ee5ad26feef1b4796c6f5567
4
- data.tar.gz: 18a322dc0c0964268450142f995e22c36d836574
3
+ metadata.gz: 316e835681bc596533571a1d66f4bba4d8a1820c
4
+ data.tar.gz: 47dda76305bca4cac07bde9a99f50c8a8f6661f0
5
5
  SHA512:
6
- metadata.gz: dd0d71faacb9941e8dd2be87ebb515b3ce8842a623864bf210f92c9cbf0cc0399c175f2a31d3320e3b87d0c74aeb38b27f287e3184a09ea347d7a89a51256105
7
- data.tar.gz: fba985b9eb5facfd853f4eec98fe3b51f06f72f562006712a6a72549d009381411a9b84549f0a4ee19d86808b370e0a5a1cdbb06eade3a29f5f66dbb2b3ec7c9
6
+ metadata.gz: 3bc6d3ac8bfe570d6b8ff1bf7507906ca0b24a13d8dcd1f6e4964bab208e860fb75a28b660565ab6aba902493117c69acfa3d8d0a76a9d1780cdb0007497bab9
7
+ data.tar.gz: ca1c3325ba192fa629b9a861fb94439666c9c1aef07f022ee5b2c35ab8197869f66c61d917341ef54eace36ded679a667098d1149e09026e4f350f8dd5b8fb52
@@ -268,7 +268,7 @@ module NLHue
268
268
  # with true and whether the lights/groups were changed, false
269
269
  # and an exception on error.
270
270
  def update &block
271
- @request_queue.get "/api/#{@username}", :info do |response|
271
+ @request_queue.get "/api/#{api_key}", :info do |response|
272
272
  status, result = check_json response
273
273
 
274
274
  changed = false
@@ -717,25 +717,25 @@ module NLHue
717
717
  # Makes a GET request under the API using this Bridge's stored
718
718
  # username.
719
719
  def get_api subpath, category=nil, &block
720
- @request_queue.get "/api/#{@username}#{subpath}", &block
720
+ @request_queue.get "/api/#{api_key}#{subpath}", &block
721
721
  end
722
722
 
723
723
  # Makes a POST request under the API using this Bridge's stored
724
724
  # username.
725
725
  def post_api subpath, data, category=nil, content_type=nil, &block
726
- @request_queue.post "/api/#{@username}#{subpath}", data, category, content_type, &block
726
+ @request_queue.post "/api/#{api_key}#{subpath}", data, category, content_type, &block
727
727
  end
728
728
 
729
729
  # Makes a PUT request under the API using this Bridge's stored
730
730
  # username.
731
731
  def put_api subpath, data, category=nil, content_type=nil, &block
732
- @request_queue.put "/api/#{@username}#{subpath}", data, category, content_type, &block
732
+ @request_queue.put "/api/#{api_key}#{subpath}", data, category, content_type, &block
733
733
  end
734
734
 
735
735
  # Makes a DELETE request under the API using this Bridge's
736
736
  # stored username.
737
737
  def delete_api subpath, category=nil, &block
738
- @request_queue.delete "/api/#{@username}#{subpath}", category, &block
738
+ @request_queue.delete "/api/#{api_key}#{subpath}", category, &block
739
739
  end
740
740
 
741
741
  # Schedules a Light, Scene, or Group to have its deferred values
@@ -771,6 +771,13 @@ module NLHue
771
771
  end
772
772
 
773
773
  private
774
+ # Returns the string to use in API URLs as the API key (the
775
+ # bridge username if registered, or an obviously invalid string
776
+ # otherwise).
777
+ def api_key
778
+ @username || 'unknown'
779
+ end
780
+
774
781
  # Sets this bridge's name (call after getting UPnP XML or
775
782
  # bridge config JSON), removing the IP address if present.
776
783
  def set_name name
@@ -23,7 +23,7 @@ module NLHue
23
23
  MAX_SUBSCRIBED_AGE = 150000
24
24
 
25
25
  # Number of times a bridge can fail to update
26
- MAX_BRIDGE_ERR = 2
26
+ MAX_BRIDGE_ERR = 4
27
27
 
28
28
  # Bridges discovered on the network
29
29
  # [serial] => {
@@ -280,7 +280,7 @@ module NLHue
280
280
  info = @@bridges[br.serial]
281
281
  @@bridges.delete br.serial
282
282
  br.remove_update_callback info[:cb]
283
- notify_bridge_removed br, 'Error updating bridge.'
283
+ notify_bridge_removed br, "Error updating bridge: #{result}"
284
284
  EM.next_tick do
285
285
  br.clean # next tick to ensure after notify*removed
286
286
  do_disco
@@ -1,3 +1,3 @@
1
1
  module NLHue
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nlhue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Bourgeous
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-29 00:00:00.000000000 Z
11
+ date: 2016-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler