openhab-scripting 4.42.0 → 4.43.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62974273127c66d888a44c8871b287dd6cfc90485ad04e9d461b407d19474eb1
4
- data.tar.gz: d9540eeb7d3df3df1075ff8c79a4bc8eef1ca9e6920860bce2c5a3c64a2931b8
3
+ metadata.gz: 3ced4a751b4de9b352e205574f4351ed291efe23b2b096b5be7f40e12cc20777
4
+ data.tar.gz: 914351269a8c397536cb1df56907891565d9214b1d11f6124543dbf91b6aa0f2
5
5
  SHA512:
6
- metadata.gz: 26fbfcddca4f673fbaf1a2399bb126c06715dfbe966ae1c0a77259bdc5b1debafbbdb9b9103c81d0c8bc31311118b44517504e749611cb0c80cc4ddea1e69e23
7
- data.tar.gz: 80e903ea1be4ce311c3f5093fa678bd38a22ddc5e97ac24245faaa5ad14cd5cd383b3e82f9cce11da6d7e062608ce5181a8eed3005f5aab09982f0a78f5eb944
6
+ metadata.gz: e6f5fd13e613a4b4b018f73236bb050b5b80f1087ac24e6747d5b5aa710920ad9b9bc6bbc56d437b4b8c8ba39f9db516995b15d64592ad813e4bee276ba79b67
7
+ data.tar.gz: fbee80a3b22ad7c2ee83c42e6294602a88b522926340fe0d5f089a76284b7742bc1d50352de8d2c087fd1a399b810f0182ea8c15f4d2e666eb86465ce6b907d1
@@ -33,7 +33,7 @@ module OpenHAB
33
33
  # @param [Hash] values Keys and values to set for running thread, if hash is nil no values are set
34
34
  #
35
35
  def thread_local(**values, &block)
36
- ThreadLocal.thread_local(values, &block)
36
+ ThreadLocal.thread_local(**values, &block)
37
37
  end
38
38
  end
39
39
  end
@@ -101,6 +101,18 @@ module OpenHAB
101
101
  volume = Types::PercentType.new(volume) unless volume.is_a?(Types::PercentType) || volume.nil?
102
102
  Audio.playSound sink&.to_s, filename.to_s, volume
103
103
  end
104
+
105
+ #
106
+ # Play an audio stream from an URL to the given sink(s). Set url to nil if streaming should be stopped
107
+ #
108
+ # @param [String] url The URL of the audio stream
109
+ # @param [String] sink The audio sink, or nil to use the default audio sink
110
+ #
111
+ # @return [void]
112
+ #
113
+ def play_stream(url, sink: nil)
114
+ Audio.playStream sink&.to_s, url
115
+ end
104
116
  end
105
117
  end
106
118
  end
@@ -37,7 +37,7 @@ module OpenHAB
37
37
  end
38
38
 
39
39
  # if we're NULL or UNDEF, implement special logic
40
- return nil_comparison unless state?
40
+ return nil_comparison(other) unless state?
41
41
 
42
42
  # delegate to how the state compares to the other object
43
43
  state <=> other
@@ -45,9 +45,10 @@ module OpenHAB
45
45
 
46
46
  # Special logic for NULL/UNDEF state comparison
47
47
  # @!visibility private
48
- def nil_comparison
48
+ def nil_comparison(other)
49
49
  # if comparing to nil, consider ourselves equal
50
50
  return 0 if other.nil?
51
+
51
52
  # if the other object is an Item, only consider equal if we're
52
53
  # in the same _kind_ of UnDefType state
53
54
  return raw_state == other.raw_state if other.is_a?(GenericItem) && !other.state?
@@ -88,6 +88,7 @@ module OpenHAB
88
88
  @item.__send__(method, *args, &block)
89
89
  end
90
90
  end
91
+ ruby2_keywords :method_missing if respond_to? :ruby2_keywords
91
92
 
92
93
  # .
93
94
  def respond_to_missing?(method, include_private = false)
@@ -220,10 +220,10 @@ module OpenHAB
220
220
  end
221
221
 
222
222
  PERSISTENCE_METHODS.each do |method|
223
- public_method = method.to_s.delete_suffix('?') # For some reason, the boolean methods with '?' are missing
224
223
  define_method(method) do |timestamp, service = nil|
225
224
  service ||= persistence_service
226
- result = PersistenceExtensions.public_send(public_method, self, to_zdt(timestamp), service&.to_s)
225
+ result = PersistenceExtensions.public_send(method.to_s.delete_suffix('?'), self, to_zdt(timestamp),
226
+ service&.to_s)
227
227
  wrap_result(result, method)
228
228
  end
229
229
 
@@ -232,8 +232,8 @@ module OpenHAB
232
232
  between_method = method.to_s.sub('_since', '_between').to_sym
233
233
  define_method(between_method) do |start, finish, service = nil|
234
234
  service ||= persistence_service
235
- result = PersistenceExtensions.public_send(public_method, self, to_zdt(start), to_zdt(finish),
236
- service&.to_s)
235
+ result = PersistenceExtensions.public_send(between_method.to_s.delete_suffix('?'), self, to_zdt(start),
236
+ to_zdt(finish), service&.to_s)
237
237
  wrap_result(result, method)
238
238
  end
239
239
  end
@@ -173,7 +173,7 @@ module OpenHAB
173
173
  def execute(_mod = nil, inputs = nil)
174
174
  OpenHAB::DSL.import_presets
175
175
  @semaphore.synchronize do
176
- thread_local(@thread_locals) do
176
+ thread_local(**@thread_locals) do
177
177
  logger.trace "Canceling implicit timer #{@timed_command_details.timer} for "\
178
178
  "#{@timed_command_details.item.id} because received event #{inputs}"
179
179
  @timed_command_details.timer.cancel
@@ -8,7 +8,6 @@ require_relative 'guard'
8
8
  require_relative 'rule_triggers'
9
9
  require 'openhab/core/entity_lookup'
10
10
  require 'openhab/dsl/between'
11
- require 'openhab/dsl/dsl'
12
11
  require 'openhab/dsl/timers'
13
12
 
14
13
  module OpenHAB
@@ -35,6 +35,7 @@ module OpenHAB
35
35
  from = Conditions::Proc.from_value(from)
36
36
  @conditions = Conditions::Proc.new(to: to, from: from)
37
37
  @duration = duration
38
+ @timer = nil
38
39
  logger.trace "Created Duration Condition To(#{to}) From(#{from}) "\
39
40
  "Conditions(#{@conditions}) Duration(#{@duration})"
40
41
  end
@@ -20,9 +20,6 @@ module OpenHAB
20
20
  class Proc
21
21
  include OpenHAB::Log
22
22
 
23
- # Proc that doesn't check any fields
24
- ANY = Proc.new.freeze
25
-
26
23
  #
27
24
  # Converts supplied ranges to procs that check range
28
25
  # @param [Array] ranges objects to convert to range proc if they are ranges
@@ -83,6 +80,9 @@ module OpenHAB
83
80
  @command = command
84
81
  end
85
82
 
83
+ # Proc that doesn't check any fields
84
+ ANY = Proc.new.freeze # this needs to be defined _after_ initialize so its instance variables are set
85
+
86
86
  #
87
87
  # Process rule
88
88
  # @param [Hash] inputs inputs from trigger
@@ -82,7 +82,7 @@ module OpenHAB
82
82
  OpenHAB::DSL.import_presets
83
83
  semaphore.synchronize do
84
84
  Timers.timer_manager.delete(self)
85
- thread_local(@thread_locals) do
85
+ thread_local(**@thread_locals) do
86
86
  yield(self)
87
87
  end
88
88
  end
@@ -212,7 +212,7 @@ module OpenHAB
212
212
  .then { |klass| java_klass(klass) }
213
213
  .then(&:name)
214
214
  .then { |name| filter_base_classes(name) }
215
- .then { |name| name&.prepend('.') }
215
+ .then { |name| ".#{name}" unless name.nil? } # name is frozen in jruby 9.4
216
216
  end
217
217
 
218
218
  # Get the appropriate java class for the supplied klass if the supplied
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '4.42.0'
8
+ VERSION = '4.43.0'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openhab-scripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.42.0
4
+ version: 4.43.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-18 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler