openhab-scripting 5.7.0 → 5.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openhab/core/actions/http.rb +24 -8
- data/lib/openhab/core/sitemaps/provider.rb +2 -2
- data/lib/openhab/core/timer.rb +2 -1
- data/lib/openhab/dsl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 951ad54507dbf4b297d59534c124c21bbf6f6b7a02e4c3fa967a5290aac9968e
|
4
|
+
data.tar.gz: d4b33c4b8cdf237c6bdc1c2b99b87459f913f2d787423f261677d469d9629df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f26471513aca95dcb0266ffca7176ee57980cbea404c8290c095642c4851954e4d870232507cbea34c6b6c4a940da84d6681944ee039199c3fcc766bdd64a598
|
7
|
+
data.tar.gz: 0c6e9e9cf72ee4a1935c399c235256144b0c6fbbb7bc0eb3f07a81405f3e52cc0193a1856ec910212f963c37208cb29191bbe90d143bf822bfc2c987828de47d
|
@@ -3,6 +3,17 @@
|
|
3
3
|
module OpenHAB
|
4
4
|
module Core
|
5
5
|
module Actions
|
6
|
+
#
|
7
|
+
# The HTTP actions allow you to send HTTP requests and receive the response.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # Send a GET request
|
11
|
+
# headers = {
|
12
|
+
# "User-Agent": "JRuby/1.2.3", # enclose in quotes if the key contains dashes
|
13
|
+
# Accept: "application/json",
|
14
|
+
# }
|
15
|
+
# response = HTTP.send_http_get_request("http://example.com/list", headers: headers)
|
16
|
+
#
|
6
17
|
# @see https://www.openhab.org/docs/configuration/actions.html#http-actions HTTP Actions
|
7
18
|
class HTTP
|
8
19
|
class << self
|
@@ -10,7 +21,8 @@ module OpenHAB
|
|
10
21
|
# Sends an HTTP GET request and returns the result as a String.
|
11
22
|
#
|
12
23
|
# @param [String] url
|
13
|
-
# @param [Hash<String, String>] headers
|
24
|
+
# @param [Hash<String, String>, Hash<Symbol, String>] headers
|
25
|
+
# A hash of headers to send with the request. Symbolic keys will be converted to strings.
|
14
26
|
# @param [Duration, int, nil] timeout Timeout (in milliseconds, if given as an Integer)
|
15
27
|
# @return [String] the response body
|
16
28
|
# @return [nil] if an error occurred
|
@@ -19,7 +31,7 @@ module OpenHAB
|
|
19
31
|
timeout ||= 5_000
|
20
32
|
timeout = timeout.to_millis if timeout.is_a?(Duration)
|
21
33
|
|
22
|
-
sendHttpGetRequest(url, headers, timeout)
|
34
|
+
sendHttpGetRequest(url, headers.transform_keys(&:to_s), timeout)
|
23
35
|
end
|
24
36
|
|
25
37
|
#
|
@@ -28,7 +40,8 @@ module OpenHAB
|
|
28
40
|
# @param [String] url
|
29
41
|
# @param [String] content_type
|
30
42
|
# @param [String] content
|
31
|
-
# @param [Hash<String, String>] headers
|
43
|
+
# @param [Hash<String, String>, Hash<Symbol, String>] headers
|
44
|
+
# A hash of headers to send with the request. Symbolic keys will be converted to strings.
|
32
45
|
# @param [Duration, int, nil] timeout Timeout (in milliseconds, if given as an Integer)
|
33
46
|
# @return [String] the response body
|
34
47
|
# @return [nil] if an error occurred
|
@@ -37,7 +50,7 @@ module OpenHAB
|
|
37
50
|
timeout ||= 1_000
|
38
51
|
timeout = timeout.to_millis if timeout.is_a?(Duration)
|
39
52
|
|
40
|
-
sendHttpPutRequest(url, content_type, content, headers, timeout)
|
53
|
+
sendHttpPutRequest(url, content_type, content, headers.transform_keys(&:to_s), timeout)
|
41
54
|
end
|
42
55
|
|
43
56
|
#
|
@@ -46,7 +59,8 @@ module OpenHAB
|
|
46
59
|
# @param [String] url
|
47
60
|
# @param [String] content_type
|
48
61
|
# @param [String] content
|
49
|
-
# @param [Hash<String, String>] headers
|
62
|
+
# @param [Hash<String, String>, Hash<Symbol, String>] headers
|
63
|
+
# A hash of headers to send with the request. Symbolic keys will be converted to strings.
|
50
64
|
# @param [Duration, int, nil] timeout Timeout (in milliseconds, if given as an Integer)
|
51
65
|
# @return [String] the response body
|
52
66
|
# @return [nil] if an error occurred
|
@@ -55,14 +69,16 @@ module OpenHAB
|
|
55
69
|
timeout ||= 1_000
|
56
70
|
timeout = timeout.to_millis if timeout.is_a?(Duration)
|
57
71
|
|
58
|
-
sendHttpPostRequest(url, content_type, content, headers, timeout)
|
72
|
+
sendHttpPostRequest(url, content_type, content, headers.transform_keys(&:to_s), timeout)
|
59
73
|
end
|
60
74
|
|
61
75
|
#
|
62
76
|
# Sends an HTTP DELETE request and returns the result as a String.
|
63
77
|
#
|
64
78
|
# @param [String] url
|
65
|
-
# @param [Hash<String, String>] headers
|
79
|
+
# @param [Hash<String, String>, Hash<Symbol, String>] headers
|
80
|
+
# A hash of headers to send with the request. Keys are strings or symbols, values are strings.
|
81
|
+
# Underscores in symbolic keys are replaced with dashes.
|
66
82
|
# @param [Duration, int, nil] timeout Timeout (in milliseconds, if given as an Integer)
|
67
83
|
# @return [String] the response body
|
68
84
|
# @return [nil] if an error occurred
|
@@ -71,7 +87,7 @@ module OpenHAB
|
|
71
87
|
timeout ||= 1_000
|
72
88
|
timeout = timeout.to_millis if timeout.is_a?(Duration)
|
73
89
|
|
74
|
-
sendHttpDeleteRequest(url, headers, timeout)
|
90
|
+
sendHttpDeleteRequest(url, headers.transform_keys(&:to_s), timeout)
|
75
91
|
end
|
76
92
|
end
|
77
93
|
end
|
@@ -70,12 +70,12 @@ module OpenHAB
|
|
70
70
|
# frame label: "Main Floor" do
|
71
71
|
# text item: MainFloor_AmbTemp
|
72
72
|
# switch item: MainFloorThermostat_TargetMode, label: "Mode", mappings: %w[off auto cool heat]
|
73
|
-
# setpoint item:
|
73
|
+
# setpoint item: MainFloorThermostat_SetPoint, label: "Set Point", visibility: "MainFloorThermostat_TargetMode!=off"
|
74
74
|
# end
|
75
75
|
# frame label: "Basement" do
|
76
76
|
# text item: Basement_AmbTemp
|
77
77
|
# switch item: BasementThermostat_TargetMode, label: "Mode", mappings: { OFF: "off", COOL: "cool", HEAT: "heat" }
|
78
|
-
# setpoint item:
|
78
|
+
# setpoint item: BasementThermostat_SetPoint, label: "Set Point", visibility: "BasementThermostat_TargetMode!=off"
|
79
79
|
# end
|
80
80
|
# end
|
81
81
|
# end
|
data/lib/openhab/core/timer.rb
CHANGED
@@ -49,7 +49,8 @@ module OpenHAB
|
|
49
49
|
@id = id
|
50
50
|
@thread_locals = thread_locals
|
51
51
|
@block = block
|
52
|
-
|
52
|
+
timer_identifier = block.source_location.join(":")
|
53
|
+
@timer = ScriptExecution.create_timer(timer_identifier, 1.minute.from_now) { execute }
|
53
54
|
reschedule!(@time)
|
54
55
|
end
|
55
56
|
|
data/lib/openhab/dsl/version.rb
CHANGED