ten_hs_server 0.1.2 → 0.1.3
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/Rakefile +0 -1
- data/lib/ten_hs_server/adapter.rb +1 -0
- data/lib/ten_hs_server/device.rb +6 -0
- data/lib/ten_hs_server/event.rb +2 -1
- data/lib/ten_hs_server/room.rb +2 -2
- data/lib/ten_hs_server/version.rb +1 -1
- data/test/fixtures/ten_hs_server/insteon_device_result.html +14 -0
- data/test/ten_hs_server/device_test.rb +11 -0
- metadata +4 -2
data/Rakefile
CHANGED
data/lib/ten_hs_server/device.rb
CHANGED
@@ -104,6 +104,7 @@ module TenHsServer
|
|
104
104
|
#
|
105
105
|
# Returns a hash describing the device.
|
106
106
|
def find id
|
107
|
+
id = URI::encode(id)
|
107
108
|
response = get "?t=99&f=GetDevice&d=#{id}"
|
108
109
|
|
109
110
|
parse_device response.body
|
@@ -117,6 +118,7 @@ module TenHsServer
|
|
117
118
|
# false = off
|
118
119
|
# true = on
|
119
120
|
def toggle id
|
121
|
+
id = URI::encode(id)
|
120
122
|
response = get "?t=99&f=ToggleDevice&d=#{id}"
|
121
123
|
|
122
124
|
parse_toggle_device response.body
|
@@ -130,6 +132,7 @@ module TenHsServer
|
|
130
132
|
# false = off
|
131
133
|
# true = on
|
132
134
|
def on id
|
135
|
+
id = URI::encode(id)
|
133
136
|
response = get "?t=99&f=DeviceOn&d=#{id}"
|
134
137
|
|
135
138
|
parse_toggle_device response.body
|
@@ -143,6 +146,7 @@ module TenHsServer
|
|
143
146
|
# false = off
|
144
147
|
# true = on
|
145
148
|
def off id
|
149
|
+
id = URI::encode(id)
|
146
150
|
response = get "?t=99&f=DeviceOff&d=#{id}"
|
147
151
|
|
148
152
|
parse_toggle_device response.body
|
@@ -154,6 +158,8 @@ module TenHsServer
|
|
154
158
|
# value - The value to give the device
|
155
159
|
#
|
156
160
|
def value(id, value)
|
161
|
+
id = URI::encode(id)
|
162
|
+
value = URI::encode(value.to_s)
|
157
163
|
response = get "?t=99&f=SetDeviceValue&d=#{id}&a=#{value}"
|
158
164
|
|
159
165
|
parse_set_device_value response.body
|
data/lib/ten_hs_server/event.rb
CHANGED
@@ -30,7 +30,8 @@ module TenHsServer
|
|
30
30
|
#
|
31
31
|
# Returns a bool describing if the event was run or not
|
32
32
|
def self.run name
|
33
|
-
|
33
|
+
name = URI::encode(name)
|
34
|
+
response = get "?t=99&f=RunEvent&d=#{name}"
|
34
35
|
|
35
36
|
parse_runevent response.body
|
36
37
|
end
|
data/lib/ten_hs_server/room.rb
CHANGED
@@ -79,7 +79,7 @@ module TenHsServer
|
|
79
79
|
# devices - An array with devices
|
80
80
|
def on devices
|
81
81
|
ids = devices.map { |device| device.id }
|
82
|
-
ids = ids.join(".")
|
82
|
+
ids = URI::encode(ids.join("."))
|
83
83
|
response = get "?t=99&f=DeviceOn&d=#{ids}"
|
84
84
|
|
85
85
|
parse_toggle_devices response.body
|
@@ -94,7 +94,7 @@ module TenHsServer
|
|
94
94
|
# true = on
|
95
95
|
def off devices
|
96
96
|
ids = devices.map { |device| device.id }
|
97
|
-
ids = ids.join(".")
|
97
|
+
ids = URI::encode(ids.join("."))
|
98
98
|
response = get "?t=99&f=DeviceOff&d=#{ids}"
|
99
99
|
|
100
100
|
parse_toggle_devices response.body
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>
|
7
|
+
|
8
|
+
</title></head><body><form name="form1" method="post" action="tenHsServer.aspx?t=99&f=GetDevice&d=Q12" id="form1">
|
9
|
+
<div>
|
10
|
+
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTkzNDcxNzcwM2RkkSlaVMiVj2zRiqjrfGv75W35YBM=" />
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<span id="Result">Q12:Dining room:Chandelier:Z-Wave Switch Multilevel:4096:1. Floor:True:3:0::9737::29.11.2012 23.23.19;</span>
|
14
|
+
</form></body></html>
|
@@ -26,6 +26,17 @@ class DeviceTest < ActiveSupport::TestCase
|
|
26
26
|
assert_equal "Chandelier", device.name
|
27
27
|
end
|
28
28
|
|
29
|
+
test "should load a single insteon device" do
|
30
|
+
TenHsServer::Device.expects(:get).with(
|
31
|
+
"?t=99&f=GetDevice&d=%5C15",
|
32
|
+
).returns(
|
33
|
+
stub body: fixture("insteon_device_result.html")
|
34
|
+
)
|
35
|
+
|
36
|
+
device = TenHsServer::Device.new "\\15"
|
37
|
+
assert_equal "Chandelier", device.name
|
38
|
+
end
|
39
|
+
|
29
40
|
test "should toggle a device" do
|
30
41
|
TenHsServer::Device.expects(:get).with(
|
31
42
|
"?t=99&f=ToggleDevice&d=Q12",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ten_hs_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- test/fixtures/ten_hs_server/dining_room_off_result.html
|
152
152
|
- test/fixtures/ten_hs_server/dining_room_on_result.html
|
153
153
|
- test/fixtures/ten_hs_server/events_result.html
|
154
|
+
- test/fixtures/ten_hs_server/insteon_device_result.html
|
154
155
|
- test/fixtures/ten_hs_server/runevent_result.html
|
155
156
|
- test/fixtures/ten_hs_server/set_device_value_result.html
|
156
157
|
- test/fixtures/ten_hs_server/toggle_device_result.html
|
@@ -193,6 +194,7 @@ test_files:
|
|
193
194
|
- test/fixtures/ten_hs_server/dining_room_off_result.html
|
194
195
|
- test/fixtures/ten_hs_server/dining_room_on_result.html
|
195
196
|
- test/fixtures/ten_hs_server/events_result.html
|
197
|
+
- test/fixtures/ten_hs_server/insteon_device_result.html
|
196
198
|
- test/fixtures/ten_hs_server/runevent_result.html
|
197
199
|
- test/fixtures/ten_hs_server/set_device_value_result.html
|
198
200
|
- test/fixtures/ten_hs_server/toggle_device_result.html
|