ten_hs_server 0.1.3 → 0.2.0
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.
data/lib/ten_hs_server.rb
CHANGED
@@ -1,8 +1,35 @@
|
|
1
|
+
# This is a ruby wrapper around the tenHsServer Homeseer API
|
2
|
+
#
|
3
|
+
# Author: Espen Høgbakk
|
4
|
+
# Email: espen@hogbakk.no
|
5
|
+
|
1
6
|
require "ten_hs_server/version"
|
2
7
|
|
3
8
|
module TenHsServer
|
9
|
+
def self.new host
|
10
|
+
@host = host
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.host
|
15
|
+
@host
|
16
|
+
end
|
17
|
+
|
4
18
|
autoload :Adapter, "ten_hs_server/adapter"
|
5
19
|
autoload :Device, "ten_hs_server/device"
|
6
20
|
autoload :Event, "ten_hs_server/event"
|
7
21
|
autoload :Room, "ten_hs_server/room"
|
22
|
+
|
23
|
+
def self.event
|
24
|
+
return TenHsServer::Event
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.device
|
28
|
+
return TenHsServer::Device
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.room
|
32
|
+
return TenHsServer::Room
|
33
|
+
end
|
34
|
+
|
8
35
|
end
|
@@ -3,6 +3,8 @@ require "active_support/all"
|
|
3
3
|
require 'ten_hs_server'
|
4
4
|
|
5
5
|
class DeviceTest < ActiveSupport::TestCase
|
6
|
+
client = TenHsServer.new '10.0.0.71'
|
7
|
+
|
6
8
|
test "should load all devices" do
|
7
9
|
TenHsServer::Device.expects(:get).with(
|
8
10
|
"?t=99&f=GetDevices",
|
@@ -10,7 +12,7 @@ class DeviceTest < ActiveSupport::TestCase
|
|
10
12
|
stub body: fixture("devices_result.html")
|
11
13
|
)
|
12
14
|
|
13
|
-
devices =
|
15
|
+
devices = client.device.all
|
14
16
|
|
15
17
|
assert_equal 13, devices.count
|
16
18
|
end
|
@@ -22,7 +24,7 @@ class DeviceTest < ActiveSupport::TestCase
|
|
22
24
|
stub body: fixture("device_result.html")
|
23
25
|
)
|
24
26
|
|
25
|
-
device =
|
27
|
+
device = client.device.new "Q12"
|
26
28
|
assert_equal "Chandelier", device.name
|
27
29
|
end
|
28
30
|
|
@@ -33,7 +35,7 @@ class DeviceTest < ActiveSupport::TestCase
|
|
33
35
|
stub body: fixture("insteon_device_result.html")
|
34
36
|
)
|
35
37
|
|
36
|
-
device =
|
38
|
+
device = client.device.new "\\15"
|
37
39
|
assert_equal "Chandelier", device.name
|
38
40
|
end
|
39
41
|
|
@@ -44,7 +46,7 @@ class DeviceTest < ActiveSupport::TestCase
|
|
44
46
|
stub body: fixture("toggle_device_result.html")
|
45
47
|
)
|
46
48
|
|
47
|
-
device =
|
49
|
+
device = client.device.new "Q12"
|
48
50
|
assert_equal 2, device.toggle[:status]
|
49
51
|
end
|
50
52
|
|
@@ -55,7 +57,7 @@ class DeviceTest < ActiveSupport::TestCase
|
|
55
57
|
stub body: fixture("device_on_result.html")
|
56
58
|
)
|
57
59
|
|
58
|
-
device =
|
60
|
+
device = client.device.new "Q12"
|
59
61
|
assert_equal 2, device.on[:status]
|
60
62
|
end
|
61
63
|
|
@@ -66,7 +68,7 @@ class DeviceTest < ActiveSupport::TestCase
|
|
66
68
|
stub body: fixture("device_off_result.html")
|
67
69
|
)
|
68
70
|
|
69
|
-
device =
|
71
|
+
device = client.device.new "Q12"
|
70
72
|
assert_equal 3, device.off[:status]
|
71
73
|
end
|
72
74
|
|
@@ -82,7 +84,7 @@ class DeviceTest < ActiveSupport::TestCase
|
|
82
84
|
stub body: fixture("set_device_value_result.html")
|
83
85
|
)
|
84
86
|
|
85
|
-
device =
|
87
|
+
device = client.device.new "Q12"
|
86
88
|
assert_equal 70, device.dim(70)
|
87
89
|
end
|
88
90
|
|
@@ -93,7 +95,7 @@ class DeviceTest < ActiveSupport::TestCase
|
|
93
95
|
stub body: fixture("device_result.html")
|
94
96
|
)
|
95
97
|
|
96
|
-
device =
|
98
|
+
device = client.device.new "Q12"
|
97
99
|
assert_equal false, device.on?
|
98
100
|
assert_equal true, device.off?
|
99
101
|
end
|
@@ -3,6 +3,8 @@ require "active_support/all"
|
|
3
3
|
require 'ten_hs_server'
|
4
4
|
|
5
5
|
class EventTest < ActiveSupport::TestCase
|
6
|
+
client = TenHsServer.new '10.0.0.71'
|
7
|
+
|
6
8
|
test "should load all events" do
|
7
9
|
TenHsServer::Event.expects(:get).with(
|
8
10
|
"?t=99&f=GetEvents",
|
@@ -10,7 +12,7 @@ class EventTest < ActiveSupport::TestCase
|
|
10
12
|
stub body: fixture("events_result.html")
|
11
13
|
)
|
12
14
|
|
13
|
-
events =
|
15
|
+
events = client.event.all
|
14
16
|
|
15
17
|
assert_equal 8, events.count
|
16
18
|
end
|
@@ -22,7 +24,7 @@ class EventTest < ActiveSupport::TestCase
|
|
22
24
|
stub body: fixture("events_result.html")
|
23
25
|
)
|
24
26
|
|
25
|
-
event =
|
27
|
+
event = client.event.find "All on"
|
26
28
|
assert_equal "All on", event
|
27
29
|
end
|
28
30
|
|
@@ -33,7 +35,7 @@ class EventTest < ActiveSupport::TestCase
|
|
33
35
|
stub body: fixture("runevent_result.html")
|
34
36
|
)
|
35
37
|
|
36
|
-
status =
|
38
|
+
status = client.event.run "All on"
|
37
39
|
assert_equal true, status
|
38
40
|
end
|
39
41
|
|
@@ -3,6 +3,8 @@ require "active_support/all"
|
|
3
3
|
require 'ten_hs_server'
|
4
4
|
|
5
5
|
class RoomTest < ActiveSupport::TestCase
|
6
|
+
client = TenHsServer.new '10.0.0.71'
|
7
|
+
|
6
8
|
test "should load all rooms" do
|
7
9
|
TenHsServer::Device.expects(:get).with(
|
8
10
|
"?t=99&f=GetDevices",
|
@@ -10,7 +12,7 @@ class RoomTest < ActiveSupport::TestCase
|
|
10
12
|
stub body: fixture("devices_result.html")
|
11
13
|
)
|
12
14
|
|
13
|
-
rooms =
|
15
|
+
rooms = client.room.all
|
14
16
|
|
15
17
|
assert_equal 5, rooms.count
|
16
18
|
end
|
@@ -22,7 +24,7 @@ class RoomTest < ActiveSupport::TestCase
|
|
22
24
|
stub body: fixture("devices_result.html")
|
23
25
|
)
|
24
26
|
|
25
|
-
room =
|
27
|
+
room = client.room.new "Dining room"
|
26
28
|
assert_equal "Dining room", room.name
|
27
29
|
assert_equal 2, room.devices.count
|
28
30
|
end
|
@@ -34,7 +36,7 @@ class RoomTest < ActiveSupport::TestCase
|
|
34
36
|
stub body: fixture("devices_result.html")
|
35
37
|
)
|
36
38
|
|
37
|
-
room =
|
39
|
+
room = client.room.new "Foobar"
|
38
40
|
assert_equal nil, room.floor
|
39
41
|
end
|
40
42
|
|
@@ -50,7 +52,7 @@ class RoomTest < ActiveSupport::TestCase
|
|
50
52
|
stub body: fixture("dining_room_on_result.html")
|
51
53
|
)
|
52
54
|
|
53
|
-
room =
|
55
|
+
room = client.room.new "Dining room"
|
54
56
|
assert_equal true, room.on
|
55
57
|
end
|
56
58
|
|
@@ -66,7 +68,7 @@ class RoomTest < ActiveSupport::TestCase
|
|
66
68
|
stub body: fixture("dining_room_off_result.html")
|
67
69
|
)
|
68
70
|
|
69
|
-
room =
|
71
|
+
room = client.room.new "Dining room"
|
70
72
|
assert_equal true, room.off
|
71
73
|
end
|
72
74
|
|
data/test/ten_hs_server_test.rb
CHANGED
@@ -2,8 +2,8 @@ require 'test/unit'
|
|
2
2
|
require "active_support/all"
|
3
3
|
|
4
4
|
class TenHsServerTest < ActiveSupport::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
test "initializing the client" do
|
6
|
+
client = TenHsServer.new '10.0.0.71'
|
7
|
+
assert_equal "10.0.0.71", client.host
|
8
|
+
end
|
9
9
|
end
|