openhab-scripting 5.7.0 → 5.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86b3b636fb3b4c119d2ed6a5d6b81bedd731456c750d28f4e16f602d75778e7c
4
- data.tar.gz: 673ed9dc1dfba2e38e1a57b01468c3a6d74a3a3fd0141c5bd9f51bc25d84e634
3
+ metadata.gz: 951ad54507dbf4b297d59534c124c21bbf6f6b7a02e4c3fa967a5290aac9968e
4
+ data.tar.gz: d4b33c4b8cdf237c6bdc1c2b99b87459f913f2d787423f261677d469d9629df3
5
5
  SHA512:
6
- metadata.gz: 5974cf573c9fe03b1cd8df81cd312a6be70e3175c1a157d19db5dee17db2ecf8afae6619b5a3f81f91a2fce1834c7c24f7fbc7a6bf3166e60106050892d4f9ca
7
- data.tar.gz: 9cced687ace50ae3bcab50ee9ad421e9bd34cabf5338b7d927c4415f540148bf2f8033f8e72b43814a0b8a94ad399b3119a3b3ea953a1215fbc8be3e915a77f5
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: MainFloorThermostate_SetPoint, label: "Set Point", visibility: "MainFloorThermostat_TargetMode!=off"
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: BasementThermostate_SetPoint, label: "Set Point", visibility: "BasementThermostat_TargetMode!=off"
78
+ # setpoint item: BasementThermostat_SetPoint, label: "Set Point", visibility: "BasementThermostat_TargetMode!=off"
79
79
  # end
80
80
  # end
81
81
  # end
@@ -49,7 +49,8 @@ module OpenHAB
49
49
  @id = id
50
50
  @thread_locals = thread_locals
51
51
  @block = block
52
- @timer = ScriptExecution.create_timer(1.minute.from_now) { execute }
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
 
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.7.0"
7
+ VERSION = "5.7.1"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openhab-scripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.7.0
4
+ version: 5.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell