huebot 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -8
- data/bin/huebot +38 -8
- data/lib/huebot/bridge.rb +24 -0
- data/lib/huebot/cli.rb +33 -1
- data/lib/huebot/client.rb +131 -0
- data/lib/huebot/compiler.rb +5 -3
- data/lib/huebot/config.rb +41 -0
- data/lib/huebot/device_mapper.rb +2 -2
- data/lib/huebot/device_state.rb +7 -0
- data/lib/huebot/group.rb +23 -0
- data/lib/huebot/light.rb +23 -0
- data/lib/huebot/version.rb +1 -1
- data/lib/huebot.rb +6 -2
- metadata +12 -17
- data/lib/hue/LICENSE +0 -22
- data/lib/hue/bridge.rb +0 -140
- data/lib/hue/client.rb +0 -141
- data/lib/hue/editable_state.rb +0 -27
- data/lib/hue/errors.rb +0 -38
- data/lib/hue/group.rb +0 -181
- data/lib/hue/light.rb +0 -177
- data/lib/hue/scene.rb +0 -50
- data/lib/hue/translate_keys.rb +0 -21
- data/lib/hue/version.rb +0 -3
- data/lib/hue.rb +0 -13
data/lib/hue/scene.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
module Hue
|
2
|
-
class Scene
|
3
|
-
include Enumerable
|
4
|
-
include TranslateKeys
|
5
|
-
|
6
|
-
# Unique identification number.
|
7
|
-
attr_reader :id
|
8
|
-
|
9
|
-
# Bridge the scene is associated with
|
10
|
-
attr_reader :bridge
|
11
|
-
|
12
|
-
# A unique, editable name given to the scene.
|
13
|
-
attr_accessor :name
|
14
|
-
|
15
|
-
# Whether or not the scene is active on a group.
|
16
|
-
attr_reader :active
|
17
|
-
|
18
|
-
def initialize(client, bridge, id, data)
|
19
|
-
@client = client
|
20
|
-
@bridge = bridge
|
21
|
-
@id = id
|
22
|
-
|
23
|
-
unpack(data)
|
24
|
-
end
|
25
|
-
|
26
|
-
def lights
|
27
|
-
@lights ||= begin
|
28
|
-
@light_ids.map do |light_id|
|
29
|
-
@client.light(light_id)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
SCENE_KEYS_MAP = {
|
37
|
-
:name => :name,
|
38
|
-
:light_ids => :lights,
|
39
|
-
:active => :active,
|
40
|
-
}
|
41
|
-
|
42
|
-
def unpack(data)
|
43
|
-
unpack_hash(data, SCENE_KEYS_MAP)
|
44
|
-
end
|
45
|
-
|
46
|
-
def base_url
|
47
|
-
"http://#{@bridge.ip}/api/#{@client.username}/scenes/#{id}"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/lib/hue/translate_keys.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Hue
|
2
|
-
module TranslateKeys
|
3
|
-
def translate_keys(hash, map)
|
4
|
-
new_hash = {}
|
5
|
-
hash.each do |key, value|
|
6
|
-
new_key = map[key.to_sym]
|
7
|
-
key = new_key if new_key
|
8
|
-
new_hash[key] = value
|
9
|
-
end
|
10
|
-
new_hash
|
11
|
-
end
|
12
|
-
|
13
|
-
def unpack_hash(hash, map)
|
14
|
-
map.each do |local_key, remote_key|
|
15
|
-
value = hash[remote_key.to_s]
|
16
|
-
next unless value
|
17
|
-
instance_variable_set("@#{local_key}", value)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/hue/version.rb
DELETED
data/lib/hue.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'hue/version'
|
2
|
-
require 'hue/errors'
|
3
|
-
require 'hue/client'
|
4
|
-
require 'hue/bridge'
|
5
|
-
require 'hue/editable_state'
|
6
|
-
require 'hue/translate_keys'
|
7
|
-
require 'hue/light'
|
8
|
-
require 'hue/group'
|
9
|
-
require 'hue/scene'
|
10
|
-
|
11
|
-
module Hue
|
12
|
-
USERNAME_RANGE = 10..40
|
13
|
-
end
|