lights 0.8.18 → 0.8.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/lights/bridge.rb +0 -1
- data/lib/lights/bulb.rb +13 -6
- data/lib/lights/bulbstate.rb +3 -4
- data/lib/lights/command.rb +1 -2
- data/lib/lights/config.rb +45 -6
- data/lib/lights/datastore.rb +1 -2
- data/lib/lights/exception.rb +1 -1
- data/lib/lights/group.rb +5 -4
- data/lib/lights/hobject.rb +1 -2
- data/lib/lights/list.rb +1 -2
- data/lib/lights/rule.rb +18 -3
- data/lib/lights/scene.rb +1 -2
- data/lib/lights/schedule.rb +11 -4
- data/lib/lights/sensor.rb +12 -21
- data/lib/lights/user.rb +1 -2
- data/lib/lights/version.rb +1 -1
- data/spec/bulb_spec.rb +7 -0
- data/spec/datastore_spec.rb +36 -6
- data/spec/group_spec.rb +139 -9
- data/spec/rule_spec.rb +0 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjUyYjgwZTU5M2I1ZjhhMDNhYjQyN2ZiYmU1NmZjMGUxNjNlZjE0MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmY0YzRlMWQ3OTE0NjczYjk4NDhkN2E4YWE1NDI5OGMyNDBlNzA1Mg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWM3ODk4ZDUyZGI1MWMyZGUyMWI3MjE0NTVmZGIzYjA1ZmJiODg2ZTc2NjZh
|
10
|
+
NWZiNzFkNzg4Njk1Nzk1YTBhYmI5MzQ2NjQ5NjQ5YzEwODhhNzEwZjM4ODJi
|
11
|
+
MDkwNjQ4ZjQwMWY2NTkyMzI2YTI5MjlhNjYyN2Y2ZDMyNWQzNmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjNkZThjYTg1YjBiOTQ2OWNmYTY5OTQyOTk2OGM4Mzg1M2YwZGUxNDkyYTdk
|
14
|
+
OTNmYWIyNGJlZmVlY2NkZDBlMWVmYWY5ZGFhNTA1ODc0OTBmNzI2MTRiOGM5
|
15
|
+
MDRmNTMzNWMxYmRhODMxYTBkYTg5OGQxMjM3MWFkMTNkZjk4OGI=
|
data/lib/lights/bridge.rb
CHANGED
data/lib/lights/bulb.rb
CHANGED
@@ -2,22 +2,29 @@ require 'lights/bulbstate'
|
|
2
2
|
require 'lights/hobject'
|
3
3
|
|
4
4
|
class Bulb < HObject
|
5
|
-
attr_reader :id, :name, :type, :
|
5
|
+
attr_reader :id, :name, :type, :sw_version, :state,
|
6
|
+
:point_symbol, :model_id, :unique_id
|
7
|
+
attr_writer :name, :state
|
6
8
|
def initialize(id,data = {})
|
7
|
-
super(data)
|
8
9
|
@id = id
|
9
10
|
@name = data["name"]
|
10
11
|
@type = data["type"]
|
11
|
-
@
|
12
|
+
@sw_version = data["swversion"]
|
13
|
+
@point_symbol = data["pointsymbol"]
|
14
|
+
@model_id = data["modelid"]
|
15
|
+
@unique_id = data["uniqueid"]
|
12
16
|
@state = BulbState.new data["state"]
|
13
17
|
end
|
14
18
|
|
15
19
|
def data
|
16
|
-
data =
|
20
|
+
data = {}
|
17
21
|
data["name"] = @name if @name
|
18
22
|
data["type"] = @type if @type
|
19
|
-
data["swversion"] = @
|
20
|
-
data["state"] = @state.data
|
23
|
+
data["swversion"] = @sw_version if @sw_version
|
24
|
+
data["state"] = @state.data unless @state.data.empty?
|
25
|
+
data["pointsymbol"] = @point_symbol if @point_symbol
|
26
|
+
data["modelid"] = @model_id if @model_id
|
27
|
+
data["uniqueid"] = @unique_id if @unique_id
|
21
28
|
data
|
22
29
|
end
|
23
30
|
end
|
data/lib/lights/bulbstate.rb
CHANGED
@@ -45,7 +45,6 @@ class BulbState < HObject
|
|
45
45
|
:reachable, :transition_time
|
46
46
|
def initialize( data = {} )
|
47
47
|
data = {} if data == nil
|
48
|
-
super
|
49
48
|
@on = data["on"]
|
50
49
|
set_bri data["bri"]
|
51
50
|
set_hue data["hue"]
|
@@ -172,8 +171,8 @@ class BulbState < HObject
|
|
172
171
|
end
|
173
172
|
|
174
173
|
def data
|
175
|
-
data =
|
176
|
-
data["on"] = @on
|
174
|
+
data = {}
|
175
|
+
data["on"] = @on unless @on.nil?
|
177
176
|
data["bri"] = @bri if @bri
|
178
177
|
data["hue"] = @hue if @hue
|
179
178
|
data["sat"] = @sat if @sat
|
@@ -182,7 +181,7 @@ class BulbState < HObject
|
|
182
181
|
data["alert"] = @alert if @alert
|
183
182
|
data["effect"] = @effect if @effect
|
184
183
|
data["colormode"] = @color_mode if @color_mode
|
185
|
-
data["reachable"] = @reachable
|
184
|
+
data["reachable"] = @reachable unless @reachable.nil?
|
186
185
|
data["transitiontime"] = @transition_time if @transition_time
|
187
186
|
data
|
188
187
|
end
|
data/lib/lights/command.rb
CHANGED
@@ -3,14 +3,13 @@ require 'lights/hobject'
|
|
3
3
|
class Command < HObject
|
4
4
|
attr_reader :address, :method, :body
|
5
5
|
def initialize(data = {})
|
6
|
-
super
|
7
6
|
@address = data["address"]
|
8
7
|
@body = data["body"]
|
9
8
|
@method = data["method"]
|
10
9
|
end
|
11
10
|
|
12
11
|
def data
|
13
|
-
data =
|
12
|
+
data = {}
|
14
13
|
data["address"] = @address if @address
|
15
14
|
data["body"] = @body if @body
|
16
15
|
data["method"] = @method if @method
|
data/lib/lights/config.rb
CHANGED
@@ -2,19 +2,58 @@ require 'lights/userlist'
|
|
2
2
|
require 'lights/hobject'
|
3
3
|
|
4
4
|
class HueConfig < HObject
|
5
|
-
attr_reader :name, :
|
5
|
+
attr_reader :name, :zigbee_channel, :mac, :dhcp,
|
6
|
+
:ip_address, :netmask, :gateway,
|
7
|
+
:proxy_address, :proxy_port, :utc,
|
8
|
+
:local_time, :time_zone, :whitelist,
|
9
|
+
:swversion, :api_version, :sw_update,
|
10
|
+
:link_button, :portal_services,
|
11
|
+
:portal_connection, :portal_state
|
6
12
|
def initialize(data = {})
|
7
|
-
super
|
8
13
|
@name = data["name"]
|
9
|
-
@
|
14
|
+
@zigbee_channel = data["zigbeechannel"]
|
15
|
+
@mac = data["mac"]
|
16
|
+
@dhcp = data["dhcp"]
|
17
|
+
@ip_address = data["ipaddress"]
|
18
|
+
@netmask = data["netmask"]
|
19
|
+
@gateway = data["gateway"]
|
20
|
+
@proxy_address = data["proxyaddress"]
|
21
|
+
@proxy_port = data["proxyport"]
|
22
|
+
@utc = data["UTC"]
|
23
|
+
@local_time = data["localtime"]
|
24
|
+
@time_zone = data["timezone"]
|
10
25
|
@whitelist = UserList.new(data["whitelist"])
|
26
|
+
@sw_version = data["swversion"]
|
27
|
+
@api_version = data["apiversion"]
|
28
|
+
@sw_update = data["swupdate"]
|
29
|
+
@link_button = data["linkbutton"]
|
30
|
+
@portal_services = data["portalservices"]
|
31
|
+
@portal_connection = data["portalconnection"]
|
32
|
+
@portal_state = data["portalstate"]
|
11
33
|
end
|
12
34
|
|
13
35
|
def data
|
14
|
-
data =
|
36
|
+
data = {}
|
15
37
|
data["name"] = @name if @name
|
16
|
-
data["
|
17
|
-
data["
|
38
|
+
data["zigbeechannel"] = @zigbee_channel if @zigbee_channel
|
39
|
+
data["mac"] = @mac if @mac
|
40
|
+
data["dhcp"] = @dhcp unless @dhcp.nil?
|
41
|
+
data["ipaddress"] = @ip_address if @ip_address
|
42
|
+
data["netmask"] = @netmask if @netmask
|
43
|
+
data["gateway"] = @gateway if @gateway
|
44
|
+
data["proxyaddress"] = @proxy_address if @proxy_address
|
45
|
+
data["proxyport"] = @proxy_port if @proxy_port
|
46
|
+
data["UTC"] = @utc if @utc
|
47
|
+
data["localtime"] = @local_time if @local_time
|
48
|
+
data["timezone"] = @time_zone if @time_zone
|
49
|
+
data["whitelist"] = @whitelist.data unless @whitelist.data.empty?
|
50
|
+
data["swversion"] = @sw_version if @sw_version
|
51
|
+
data["apiversion"] = @api_version if @api_version
|
52
|
+
data["swupdate"] = @sw_update unless @sw_update.nil?
|
53
|
+
data["linkbutton"] = @link_button unless @link_button.nil?
|
54
|
+
data["portalservices"] = @portal_services unless @portal_services.nil?
|
55
|
+
data["portalconnection"] = @portal_connection if @portal_connection
|
56
|
+
data["portalstate"] = @portal_state unless @portal_state.nil?
|
18
57
|
data
|
19
58
|
end
|
20
59
|
end
|
data/lib/lights/datastore.rb
CHANGED
@@ -11,7 +11,6 @@ class Datastore < HObject
|
|
11
11
|
attr_reader :lights, :groups, :config, :rules,
|
12
12
|
:scenes, :schedules, :sensors
|
13
13
|
def initialize(data = {})
|
14
|
-
super
|
15
14
|
@lights = BulbList.new(data["lights"])
|
16
15
|
@groups = GroupList.new(data["groups"])
|
17
16
|
@config = HueConfig.new(data["config"])
|
@@ -32,7 +31,7 @@ class Datastore < HObject
|
|
32
31
|
end
|
33
32
|
|
34
33
|
def data
|
35
|
-
data =
|
34
|
+
data = {}
|
36
35
|
data["lights"] = @lights.data if !@lights.data.empty?
|
37
36
|
data["groups"] = @groups.data if !@groups.data.empty?
|
38
37
|
data["config"] = @config.data if !@config.data.empty?
|
data/lib/lights/exception.rb
CHANGED
data/lib/lights/group.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
require 'lights/hobject'
|
2
2
|
|
3
3
|
class Group < HObject
|
4
|
-
attr_reader :id, :data, :name, :lights, :action
|
4
|
+
attr_reader :id, :data, :name, :lights, :action, :type
|
5
5
|
attr_writer :name, :lights, :action
|
6
6
|
def initialize( id = nil, data = {} )
|
7
|
-
super(data)
|
8
7
|
@id = id
|
9
8
|
@action = BulbState.new(data["action"])
|
10
9
|
@name = data["name"]
|
11
10
|
@lights = data["lights"]
|
11
|
+
@type = data["type"]
|
12
12
|
end
|
13
13
|
|
14
14
|
def data
|
15
|
-
data =
|
15
|
+
data = {}
|
16
16
|
data["name"] = @name if @name
|
17
17
|
data["lights"] = @lights if @lights
|
18
|
-
data["
|
18
|
+
data["type"] = @type if @type
|
19
|
+
data["action"] = @action.data unless @action.data.empty?
|
19
20
|
data
|
20
21
|
end
|
21
22
|
end
|
data/lib/lights/hobject.rb
CHANGED
data/lib/lights/list.rb
CHANGED
data/lib/lights/rule.rb
CHANGED
@@ -1,16 +1,31 @@
|
|
1
1
|
require 'lights/hobject'
|
2
2
|
|
3
3
|
class Rule < HObject
|
4
|
-
attr_reader :id, :
|
4
|
+
attr_reader :id, :name, :owner, :created,
|
5
|
+
:last_triggered, :times_triggered,
|
6
|
+
:status, :conditions, :actions
|
5
7
|
def initialize( id = nil, data = {} )
|
6
|
-
super(data)
|
7
8
|
@id = id
|
8
9
|
@name = data["name"]
|
10
|
+
@owner = data["owner"]
|
11
|
+
@created = data["created"]
|
12
|
+
@last_triggered = data["lasttriggered"]
|
13
|
+
@times_triggered = data["timestriggered"]
|
14
|
+
@status = data["status"]
|
15
|
+
@conditions = data["conditions"]
|
16
|
+
@actions = data["actions"]
|
9
17
|
end
|
10
18
|
|
11
19
|
def data
|
12
|
-
data =
|
20
|
+
data = {}
|
13
21
|
data["name"] = @name if @name
|
22
|
+
data["owner"] = @owner if @owner
|
23
|
+
data["created"] = @created if @created
|
24
|
+
data["lasttriggered"] = @last_triggered if @last_triggered
|
25
|
+
data["timestriggered"] = @times_triggered if @times_triggered
|
26
|
+
data["status"] = @status if @status
|
27
|
+
data["conditions"] = @conditions if @conditions
|
28
|
+
data["actions"] = @actions if @actions
|
14
29
|
data
|
15
30
|
end
|
16
31
|
end
|
data/lib/lights/scene.rb
CHANGED
@@ -3,7 +3,6 @@ require 'lights/hobject'
|
|
3
3
|
class Scene < HObject
|
4
4
|
attr_accessor :id, :name, :active, :lights
|
5
5
|
def initialize(id,data = {})
|
6
|
-
super(data)
|
7
6
|
@id = id
|
8
7
|
@name = data["name"]
|
9
8
|
@active = data["active"]
|
@@ -13,7 +12,7 @@ class Scene < HObject
|
|
13
12
|
def data
|
14
13
|
data = {}
|
15
14
|
data["name"] = @name if @name
|
16
|
-
data["active"] = @active
|
15
|
+
data["active"] = @active unless @active.nil?
|
17
16
|
data["lights"] = @lights if @lights
|
18
17
|
data
|
19
18
|
end
|
data/lib/lights/schedule.rb
CHANGED
@@ -2,13 +2,17 @@ require 'lights/command'
|
|
2
2
|
require 'lights/hobject'
|
3
3
|
|
4
4
|
class Schedule < HObject
|
5
|
-
attr_reader :id, :name, :time, :status
|
5
|
+
attr_reader :id, :name, :time, :status,
|
6
|
+
:description, :local_time,
|
7
|
+
:created, :command
|
6
8
|
def initialize(id,data = {})
|
7
|
-
super(data)
|
8
9
|
@id = id
|
9
10
|
@name = data["name"]
|
10
11
|
@time = data["time"]
|
11
12
|
@status = data["status"]
|
13
|
+
@description = data["description"]
|
14
|
+
@local_time = data["localtime"]
|
15
|
+
@created = data["created"]
|
12
16
|
@command = Command.new(data["command"])
|
13
17
|
end
|
14
18
|
|
@@ -17,11 +21,14 @@ class Schedule < HObject
|
|
17
21
|
end
|
18
22
|
|
19
23
|
def data
|
20
|
-
data =
|
24
|
+
data = {}
|
21
25
|
data["name"] = @name if @name
|
22
26
|
data["time"] = @time if @time
|
23
27
|
data["status"] = @status if @status
|
24
|
-
data["
|
28
|
+
data["description"] = @description if @description
|
29
|
+
data["localtime"] = @local_time if @local_time
|
30
|
+
data["created"] = @created if @created
|
31
|
+
data["command"] = @command.data unless @command.data.empty?
|
25
32
|
data
|
26
33
|
end
|
27
34
|
end
|
data/lib/lights/sensor.rb
CHANGED
@@ -1,35 +1,25 @@
|
|
1
1
|
class SensorState < HObject
|
2
2
|
attr_reader :last_updated
|
3
3
|
def initialize(data)
|
4
|
-
super
|
5
4
|
@last_updated = data["lastupdated"]
|
5
|
+
@daylight = data["daylight"]
|
6
|
+
@button_event = data["buttonevent"]
|
6
7
|
end
|
7
8
|
|
8
9
|
def data
|
9
|
-
data =
|
10
|
+
data = {}
|
10
11
|
data["lastupdated"] = @last_updated if @last_updated
|
11
|
-
data
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
class TapState < SensorState
|
16
|
-
attr_reader :button_event
|
17
|
-
def initialize(data)
|
18
|
-
super
|
19
|
-
@button_event = data["button_event"]
|
20
|
-
end
|
21
|
-
|
22
|
-
def data
|
23
|
-
data = @data
|
24
|
-
data["button_event"] = @button_event if @button_event
|
12
|
+
data["daylight"] = @daylight unless @daylight.nil?
|
13
|
+
data["buttonevent"] = @button_event if @button_event
|
25
14
|
data
|
26
15
|
end
|
27
16
|
end
|
28
17
|
|
29
18
|
class Sensor < HObject
|
30
|
-
attr_reader :id, :data, :name, :type, :model_id,
|
19
|
+
attr_reader :id, :data, :name, :type, :model_id,
|
20
|
+
:manufacturer_name, :unique_id,
|
21
|
+
:sw_version, :state
|
31
22
|
def initialize( id, data = {} )
|
32
|
-
super(data)
|
33
23
|
@id = id
|
34
24
|
@name = data["name"]
|
35
25
|
@type = data["type"]
|
@@ -37,19 +27,20 @@ class Sensor < HObject
|
|
37
27
|
@manufacturer_name = data["manufacturername"]
|
38
28
|
@unique_id = data["uniqueid"]
|
39
29
|
@sw_version = data["swversion"]
|
30
|
+
@config = data["config"]
|
40
31
|
@state = SensorState.new(data["state"])
|
41
|
-
#@config = SensorConfig.new(data["config"])
|
42
32
|
end
|
43
33
|
|
44
34
|
def data
|
45
|
-
data =
|
35
|
+
data = {}
|
46
36
|
data["name"] = @name if @name
|
47
37
|
data["type"] = @type if @type
|
48
38
|
data["modelid"] = @model_id if @model_id
|
49
39
|
data["manufacturername"] = @manufacturer_name if @manufacturer_name
|
50
40
|
data["uniqueid"] = @unique_id if @unique_id
|
51
41
|
data["swversion"] = @sw_version if @sw_version
|
52
|
-
data["
|
42
|
+
data["config"] = @config if @config
|
43
|
+
data["state"] = @state.data unless @state.data.empty?
|
53
44
|
data
|
54
45
|
end
|
55
46
|
end
|
data/lib/lights/user.rb
CHANGED
@@ -3,7 +3,6 @@ require 'lights/hobject'
|
|
3
3
|
class User < HObject
|
4
4
|
attr_reader :id, :name, :create_date, :last_use_date
|
5
5
|
def initialize( id, data = {} )
|
6
|
-
super(data)
|
7
6
|
@id = id
|
8
7
|
@name = data["name"]
|
9
8
|
@create_date = data["create date"]
|
@@ -11,7 +10,7 @@ class User < HObject
|
|
11
10
|
end
|
12
11
|
|
13
12
|
def data
|
14
|
-
data =
|
13
|
+
data = {}
|
15
14
|
data["name"] = @name if @name
|
16
15
|
data["create date"] = @create_date if @create_date
|
17
16
|
data["last use date"] = @last_use_date if @last_use_date
|
data/lib/lights/version.rb
CHANGED
data/spec/bulb_spec.rb
CHANGED
@@ -7,6 +7,13 @@ describe Bulb do
|
|
7
7
|
bulb.name.should eql "test name"
|
8
8
|
end
|
9
9
|
|
10
|
+
it "properly set name parameter" do
|
11
|
+
data = { "name" => "test name" }
|
12
|
+
bulb = Bulb.new(1,data)
|
13
|
+
bulb.name = "new test name"
|
14
|
+
bulb.name.should eql "new test name"
|
15
|
+
end
|
16
|
+
|
10
17
|
it "properly creates state object" do
|
11
18
|
data = {
|
12
19
|
"name" => "test name",
|
data/spec/datastore_spec.rb
CHANGED
@@ -2,15 +2,45 @@ require 'lights'
|
|
2
2
|
|
3
3
|
describe Datastore do
|
4
4
|
it "properly reconstructs sub objects" do
|
5
|
+
data = JSON.parse(DATASTORE_JSON)
|
6
|
+
ds = Datastore.new data
|
7
|
+
ds.data.should eql data
|
8
|
+
end
|
9
|
+
|
10
|
+
it "properly reconstructs light objects" do
|
5
11
|
data = JSON.parse(DATASTORE_JSON)
|
6
12
|
ds = Datastore.new data
|
7
13
|
ds.lights.data.should eql data["lights"]
|
14
|
+
end
|
15
|
+
it "properly reconstructs group objects" do
|
16
|
+
data = JSON.parse(DATASTORE_JSON)
|
17
|
+
ds = Datastore.new data
|
8
18
|
ds.groups.data.should eql data["groups"]
|
19
|
+
end
|
20
|
+
it "properly reconstructs rule objects" do
|
21
|
+
data = JSON.parse(DATASTORE_JSON)
|
22
|
+
ds = Datastore.new data
|
9
23
|
ds.rules.data.should eql data["rules"]
|
24
|
+
end
|
25
|
+
it "properly reconstructs scene objects" do
|
26
|
+
data = JSON.parse(DATASTORE_JSON)
|
27
|
+
ds = Datastore.new data
|
10
28
|
ds.scenes.data.should eql data["scenes"]
|
29
|
+
end
|
30
|
+
it "properly reconstructs schedule objects" do
|
31
|
+
data = JSON.parse(DATASTORE_JSON)
|
32
|
+
ds = Datastore.new data
|
11
33
|
ds.schedules.data.should eql data["schedules"]
|
34
|
+
end
|
35
|
+
it "properly reconstructs sensor objects" do
|
36
|
+
data = JSON.parse(DATASTORE_JSON)
|
37
|
+
ds = Datastore.new data
|
12
38
|
ds.sensors.data.should eql data["sensors"]
|
13
|
-
|
39
|
+
end
|
40
|
+
it "properly reconstructs config object" do
|
41
|
+
data = JSON.parse(DATASTORE_JSON)
|
42
|
+
ds = Datastore.new data
|
43
|
+
ds.config.data.should eql data["config"]
|
14
44
|
end
|
15
45
|
end
|
16
46
|
|
@@ -19,7 +49,7 @@ DATASTORE_JSON = %Q{
|
|
19
49
|
"lights": {
|
20
50
|
"1": {
|
21
51
|
"state": {
|
22
|
-
"on":
|
52
|
+
"on": false,
|
23
53
|
"bri": 254,
|
24
54
|
"hue": 34495,
|
25
55
|
"sat": 232,
|
@@ -31,7 +61,7 @@ DATASTORE_JSON = %Q{
|
|
31
61
|
"ct": 155,
|
32
62
|
"alert": "none",
|
33
63
|
"colormode": "xy",
|
34
|
-
"reachable":
|
64
|
+
"reachable": false
|
35
65
|
},
|
36
66
|
"type": "Extended color light",
|
37
67
|
"name": "Hue Lamp 1",
|
@@ -227,7 +257,7 @@ DATASTORE_JSON = %Q{
|
|
227
257
|
"name": "Philips hue",
|
228
258
|
"zigbeechannel": 25,
|
229
259
|
"mac": "00:11:22:33:44:55",
|
230
|
-
"dhcp":
|
260
|
+
"dhcp": false,
|
231
261
|
"ipaddress": "192.168.1.27",
|
232
262
|
"netmask": "255.255.255.0",
|
233
263
|
"gateway": "192.168.1.1",
|
@@ -269,7 +299,7 @@ DATASTORE_JSON = %Q{
|
|
269
299
|
"notify": false
|
270
300
|
},
|
271
301
|
"linkbutton": false,
|
272
|
-
"portalservices":
|
302
|
+
"portalservices": false,
|
273
303
|
"portalconnection": "connected",
|
274
304
|
"portalstate": {
|
275
305
|
"signedon": true,
|
@@ -320,7 +350,7 @@ DATASTORE_JSON = %Q{
|
|
320
350
|
"4",
|
321
351
|
"5"
|
322
352
|
],
|
323
|
-
"active":
|
353
|
+
"active": false
|
324
354
|
},
|
325
355
|
"da01b1eaf-on-0": {
|
326
356
|
"name": "Purple on 0",
|
data/spec/group_spec.rb
CHANGED
@@ -2,22 +2,152 @@ require 'lights'
|
|
2
2
|
|
3
3
|
describe Group do
|
4
4
|
it "properly parses input parameters" do
|
5
|
-
data =
|
6
|
-
"key1" => "value 1",
|
7
|
-
"key2" => "value 2",
|
8
|
-
}
|
5
|
+
data = JSON.parse(GROUPS_JSON)["1"]
|
9
6
|
group = Group.new(1,data)
|
10
7
|
group.id.should eql 1
|
11
|
-
group.
|
8
|
+
group.name.should eql "Ceiling light"
|
9
|
+
group.type.should eql "LightGroup"
|
10
|
+
group.lights.should eql ["1","2","3","4"]
|
12
11
|
end
|
13
12
|
|
14
13
|
it "properly reconstucts object hash" do
|
15
|
-
data =
|
16
|
-
"key1" => "value 1",
|
17
|
-
"key2" => "value 2",
|
18
|
-
}
|
14
|
+
data = JSON.parse(GROUPS_JSON)["1"]
|
19
15
|
group = Group.new(1,data)
|
20
16
|
group.id.should eql 1
|
21
17
|
group.data.should eql data
|
22
18
|
end
|
23
19
|
end
|
20
|
+
|
21
|
+
GROUPS_JSON = %Q{
|
22
|
+
{
|
23
|
+
"1": {
|
24
|
+
"name": "Ceiling light",
|
25
|
+
"lights": [
|
26
|
+
"1",
|
27
|
+
"2",
|
28
|
+
"3",
|
29
|
+
"4"
|
30
|
+
],
|
31
|
+
"type": "LightGroup",
|
32
|
+
"action": {
|
33
|
+
"on": true,
|
34
|
+
"bri": 254,
|
35
|
+
"hue": 56100,
|
36
|
+
"sat": 232,
|
37
|
+
"effect": "none",
|
38
|
+
"xy": [
|
39
|
+
0.4119,
|
40
|
+
0.1949
|
41
|
+
],
|
42
|
+
"ct": 293,
|
43
|
+
"colormode": "xy"
|
44
|
+
}
|
45
|
+
},
|
46
|
+
"2": {
|
47
|
+
"name": "Lamp",
|
48
|
+
"lights": [
|
49
|
+
"5"
|
50
|
+
],
|
51
|
+
"type": "LightGroup",
|
52
|
+
"action": {
|
53
|
+
"on": true,
|
54
|
+
"bri": 254,
|
55
|
+
"hue": 56100,
|
56
|
+
"sat": 232,
|
57
|
+
"effect": "none",
|
58
|
+
"xy": [
|
59
|
+
0.4119,
|
60
|
+
0.1949
|
61
|
+
],
|
62
|
+
"ct": 293,
|
63
|
+
"colormode": "xy"
|
64
|
+
}
|
65
|
+
},
|
66
|
+
"3": {
|
67
|
+
"name": "HueCraft_Ambiance1",
|
68
|
+
"lights": [
|
69
|
+
"1",
|
70
|
+
"2"
|
71
|
+
],
|
72
|
+
"type": "LightGroup",
|
73
|
+
"action": {
|
74
|
+
"on": true,
|
75
|
+
"bri": 254,
|
76
|
+
"hue": 56100,
|
77
|
+
"sat": 232,
|
78
|
+
"effect": "none",
|
79
|
+
"xy": [
|
80
|
+
0.4119,
|
81
|
+
0.1949
|
82
|
+
],
|
83
|
+
"ct": 293,
|
84
|
+
"colormode": "xy"
|
85
|
+
}
|
86
|
+
},
|
87
|
+
"4": {
|
88
|
+
"name": "HueCraft_Ambiance2",
|
89
|
+
"lights": [
|
90
|
+
"3",
|
91
|
+
"4"
|
92
|
+
],
|
93
|
+
"type": "LightGroup",
|
94
|
+
"action": {
|
95
|
+
"on": true,
|
96
|
+
"bri": 254,
|
97
|
+
"hue": 56100,
|
98
|
+
"sat": 232,
|
99
|
+
"effect": "none",
|
100
|
+
"xy": [
|
101
|
+
0.4119,
|
102
|
+
0.1949
|
103
|
+
],
|
104
|
+
"ct": 293,
|
105
|
+
"colormode": "xy"
|
106
|
+
}
|
107
|
+
},
|
108
|
+
"5": {
|
109
|
+
"name": "HueCraft_Effect1",
|
110
|
+
"lights": [
|
111
|
+
"5"
|
112
|
+
],
|
113
|
+
"type": "LightGroup",
|
114
|
+
"action": {
|
115
|
+
"on": true,
|
116
|
+
"bri": 254,
|
117
|
+
"hue": 56100,
|
118
|
+
"sat": 232,
|
119
|
+
"effect": "none",
|
120
|
+
"xy": [
|
121
|
+
0.4119,
|
122
|
+
0.1949
|
123
|
+
],
|
124
|
+
"ct": 293,
|
125
|
+
"colormode": "xy"
|
126
|
+
}
|
127
|
+
},
|
128
|
+
"6": {
|
129
|
+
"name": "HueCraft_HueCraft",
|
130
|
+
"lights": [
|
131
|
+
"1",
|
132
|
+
"2",
|
133
|
+
"3",
|
134
|
+
"4",
|
135
|
+
"5"
|
136
|
+
],
|
137
|
+
"type": "LightGroup",
|
138
|
+
"action": {
|
139
|
+
"on": true,
|
140
|
+
"bri": 254,
|
141
|
+
"hue": 56100,
|
142
|
+
"sat": 232,
|
143
|
+
"effect": "none",
|
144
|
+
"xy": [
|
145
|
+
0.4119,
|
146
|
+
0.1949
|
147
|
+
],
|
148
|
+
"ct": 293,
|
149
|
+
"colormode": "xy"
|
150
|
+
}
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
data/spec/rule_spec.rb
CHANGED