openhab-scripting 5.45.0 → 5.46.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a6ff4c8c427bbcf314fb2226da8fcc4791ee9395394f404e88567a4417e1b4f
4
- data.tar.gz: 254980e2b97d5cd3f3c44990ed5e1cd84e0c31d2a8a9490146d317e0c2f3d9a9
3
+ metadata.gz: e6351743424c867636542a49ecdb2ef2eca63824d2009ae517763d256f7fab20
4
+ data.tar.gz: 72d778a25df32f555763c38539c1bb7d34ae2f24c70120d069504d18e036eaac
5
5
  SHA512:
6
- metadata.gz: 01b946e0402acf49358f2de450960fd716f654c668bd40f419a5c768672d2bd7272fa89d5bef1c0e7f61f57968156c2a9d9b2a47b01b0e6065432962df568a12
7
- data.tar.gz: 6ef1bc5b35034eac211a4024586e04d27c8aeeba8f2e7d21ab6999ba32b6d72c567a29c81010b559685af51d2bd69d461ea32726149c044fe090a8aa757fd09f
6
+ metadata.gz: a6d35c4a0489003faeabf001e3215bb8f4e9e805cdffb69ba0b10d9261127f08f07f1c0e61cc072ff849eab6dc70c88d9b11003c9f830c53e93ff92ce5ae03ce
7
+ data.tar.gz: 0be0d9f6149485518eabb0b4c08bb4a73ce7fdf7c9d231e9c9ee590f132a74f647dcbb4c3e3d1087dd2be10a1f487736e45214af2037e2093f019de3d3aeadda
@@ -91,22 +91,19 @@ module OpenHAB
91
91
  tag ||= severity
92
92
  args.push(msg.to_s, icon&.to_s, tag&.to_s)
93
93
 
94
- # @deprecated OH 4.1
95
- if Core.version >= Core::V4_2
96
- buttons ||= []
97
- buttons = buttons.map { |button_title, action| "#{button_title}=#{action}" } if buttons.is_a?(Hash)
98
- raise ArgumentError, "buttons must contain (0..3) elements." unless (0..3).cover?(buttons.size)
94
+ buttons ||= []
95
+ buttons = buttons.map { |button_title, action| "#{button_title}=#{action}" } if buttons.is_a?(Hash)
96
+ raise ArgumentError, "buttons must contain (0..3) elements." unless (0..3).cover?(buttons.size)
99
97
 
100
- attachment = "item:#{attachment.name}" if attachment.is_a?(Item) && attachment.image_item?
98
+ attachment = "item:#{attachment.name}" if attachment.is_a?(Item) && attachment.image_item?
101
99
 
102
- args.push(title&.to_s,
103
- id&.to_s,
104
- on_click&.to_s,
105
- attachment&.to_s,
106
- buttons[0]&.to_s,
107
- buttons[1]&.to_s,
108
- buttons[2]&.to_s)
109
- end
100
+ args.push(title&.to_s,
101
+ id&.to_s,
102
+ on_click&.to_s,
103
+ attachment&.to_s,
104
+ buttons[0]&.to_s,
105
+ buttons[1]&.to_s,
106
+ buttons[2]&.to_s)
110
107
 
111
108
  NotificationAction.__send__(*args)
112
109
  end
@@ -53,9 +53,9 @@ module OpenHAB
53
53
  # @!method notify(msg, email: nil, icon: nil, tag: nil, severity: nil, id: nil, title: nil, on_click: nil, attachment: nil, buttons: nil)
54
54
  # @deprecated Use {Notification.send Notification.send} instead.
55
55
  #
56
- def notify(*args, **kwargs)
56
+ def notify(*, **)
57
57
  logger.warn("`notify` method is deprecated. Use `Notification.send` instead.")
58
- Notification.send(*args, **kwargs)
58
+ Notification.send(*, **)
59
59
  end
60
60
  end
61
61
  end
@@ -137,9 +137,9 @@ module OpenHAB
137
137
  end
138
138
 
139
139
  # @!visibility private
140
- def instance_eval_with_dummy_items(&block)
140
+ def instance_eval_with_dummy_items(&)
141
141
  DSL::ThreadLocal.thread_local(openhab_create_dummy_items: self.class.create_dummy_items?) do
142
- instance_eval(&block)
142
+ instance_eval(&)
143
143
  end
144
144
  end
145
145
 
@@ -82,9 +82,8 @@ module OpenHAB
82
82
  def inspect
83
83
  s = "#<OpenHAB::Core::Events::ItemStateChangedEvent item=#{item_name} " \
84
84
  "state=#{item_state.inspect} was=#{old_item_state.inspect}"
85
- # @deprecated OH4.3 remove respond_to? checks in the next two lines when dropping OH 4.3
86
- s += " last_state_update=#{last_state_update}" if respond_to?(:last_state_update) && last_state_update
87
- s += " last_state_change=#{last_state_change}" if respond_to?(:last_state_change) && last_state_change
85
+ s += " last_state_update=#{last_state_update}" if last_state_update
86
+ s += " last_state_change=#{last_state_change}" if last_state_change
88
87
  s += " source=#{source.inspect}" if source
89
88
  "#{s}>"
90
89
  end
@@ -670,15 +670,6 @@ module OpenHAB
670
670
  # @since openHAB 4.2
671
671
  #
672
672
  def persist(*args)
673
- # @deprecated OH 4.1 this if block content can be removed when dropping OH 4.1 support
674
- if Core.version < Core::V4_2
675
- raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0..1)" if args.size > 1
676
-
677
- service = args.last || persistence_service
678
- Actions::PersistenceExtensions.persist(self, service&.to_s)
679
- return
680
- end
681
-
682
673
  first_arg = args.first
683
674
  if first_arg.is_a?(TimeSeries)
684
675
  if args.size > 2
@@ -752,9 +743,6 @@ module OpenHAB
752
743
  # @since openHAB 4.2
753
744
 
754
745
  %i[last_update next_update last_change next_change].each do |method|
755
- # @deprecated OH 4.1 remove this guard when dropping OH 4.1
756
- next unless Actions::PersistenceExtensions.respond_to?(method)
757
-
758
746
  class_eval <<~RUBY, __FILE__, __LINE__ + 1
759
747
  def #{method}(service = nil) # def last_update(service = nil)
760
748
  service ||= persistence_service # service ||= persistence_service
@@ -794,9 +782,6 @@ module OpenHAB
794
782
  # @since openHAB 4.2
795
783
 
796
784
  %i[previous_state next_state].each do |method|
797
- # @deprecated OH 4.1 remove this guard when dropping OH 4.1
798
- next unless Actions::PersistenceExtensions.respond_to?(method)
799
-
800
785
  class_eval <<~RUBY, __FILE__, __LINE__ + 1
801
786
  def #{method}(service = nil, skip_equal: false) # def previous_state(service = nil, skip_equal: false)
802
787
  service ||= persistence_service # service ||= persistence_service
@@ -819,10 +804,7 @@ module OpenHAB
819
804
 
820
805
  if riemann_param
821
806
  riemann_param = ", riemann_type: nil"
822
- # @deprecated OH4.3 remove if guard when dropping OH 4.3
823
- if Actions::PersistenceExtensions.const_defined?(:RiemannType)
824
- riemann_arg = "to_riemann_type(riemann_type),"
825
- end
807
+ riemann_arg = "to_riemann_type(riemann_type),"
826
808
  end
827
809
 
828
810
  class_eval <<~RUBY, __FILE__, __LINE__ + 1
@@ -846,17 +828,11 @@ module OpenHAB
846
828
  riemann_arg = nil
847
829
 
848
830
  def_persistence_method("#{method}_since#{suffix}", quantify:, riemann_param:)
849
- # @deprecated OH 4.1 remove if guard, keeping the content, when dropping OH 4.1
850
- if OpenHAB::Core.version >= OpenHAB::Core::V4_2
851
- def_persistence_method("#{method}_until#{suffix}", quantify:, riemann_param:)
852
- end
831
+ def_persistence_method("#{method}_until#{suffix}", quantify:, riemann_param:)
853
832
 
854
833
  if riemann_param
855
834
  riemann_param = ", riemann_type: nil"
856
- # @deprecated OH4.3 remove if guard when dropping OH 4.3
857
- if Actions::PersistenceExtensions.const_defined?(:RiemannType)
858
- riemann_arg = "to_riemann_type(riemann_type),"
859
- end
835
+ riemann_arg = "to_riemann_type(riemann_type),"
860
836
  end
861
837
 
862
838
  method = "#{method}_between"
@@ -889,7 +865,7 @@ module OpenHAB
889
865
 
890
866
  def_persistence_methods(:count_state_changes)
891
867
  alias_method :state_changes_since, :count_state_changes_since
892
- alias_method :state_changes_until, :count_state_changes_until if OpenHAB::Core.version >= OpenHAB::Core::V4_2
868
+ alias_method :state_changes_until, :count_state_changes_until
893
869
  alias_method :state_changes_between, :count_state_changes_between
894
870
 
895
871
  def_persistence_methods(:delta, quantify: true)
@@ -900,27 +876,21 @@ module OpenHAB
900
876
 
901
877
  def_persistence_methods(:get_all_states, quantify: true)
902
878
  alias_method :all_states_since, :get_all_states_since
903
- alias_method :all_states_until, :get_all_states_until if OpenHAB::Core.version >= OpenHAB::Core::V4_2
879
+ alias_method :all_states_until, :get_all_states_until
904
880
  alias_method :all_states_between, :get_all_states_between
905
881
 
906
882
  def_persistence_methods(:maximum, quantify: true)
907
883
  def_persistence_methods(:minimum, quantify: true)
908
- def_persistence_methods(:median, quantify: true) if OpenHAB::Core.version >= OpenHAB::Core::V4_3
909
- # @deprecated OH4.3 remove if guard when dropping OH 4.3
910
- if Actions::PersistenceExtensions.const_defined?(:RiemannType)
911
- # riemann_sum methods were added in OH 5.0 which already quantifies the result in core
912
- def_persistence_methods(:riemann_sum, riemann_param: true)
913
- end
884
+ def_persistence_methods(:median, quantify: true)
885
+ def_persistence_methods(:riemann_sum, riemann_param: true) # already quantified in core
914
886
  def_persistence_methods(:sum, quantify: true)
915
887
  def_persistence_methods(:updated?)
916
888
  def_persistence_methods(:variance, quantify: true, riemann_param: true)
917
889
 
918
- if OpenHAB::Core.version >= OpenHAB::Core::V4_2
919
- def_persistence_method(:persisted_state) # already quantified in core
890
+ def_persistence_method(:persisted_state) # already quantified in core
920
891
 
921
- def_persistence_methods(:evolution_rate)
922
- def_persistence_methods(:remove_all_states)
923
- end
892
+ def_persistence_methods(:evolution_rate)
893
+ def_persistence_methods(:remove_all_states)
924
894
 
925
895
  # @deprecated OH 4.2 this method is deprecated in OH 4.2 and may be removed in a future version
926
896
  def evolution_rate(start, finish_or_service = nil, service = nil)
@@ -52,9 +52,9 @@ module OpenHAB
52
52
  #
53
53
  # @see DSL::Items::Builder DSL::Items::Builder for more details and examples
54
54
  #
55
- def build(preferred_provider = nil, update: true, &block)
55
+ def build(preferred_provider = nil, update: true, &)
56
56
  DSL::Items::BaseBuilderDSL.new(preferred_provider, update:)
57
- .instance_eval_with_dummy_items(&block)
57
+ .instance_eval_with_dummy_items(&)
58
58
  end
59
59
 
60
60
  #
@@ -97,16 +97,16 @@ module Enumerable
97
97
  # Send a command to every item in the collection
98
98
  # @return [self, nil] nil when `ensure` is in effect and all the items were already in the same state,
99
99
  # otherwise self
100
- def command(command, **kwargs)
101
- self if count { |i| i.command(command, **kwargs) }.positive?
100
+ def command(command, **)
101
+ self if count { |i| i.command(command, **) }.positive?
102
102
  end
103
103
 
104
104
  # Send a command to every item in the collection, even when {OpenHAB::DSL.ensure_states! ensure_states!} is in effect.
105
105
  # @return [self]
106
- def command!(command, **kwargs)
106
+ def command!(command, **)
107
107
  # We cannot alias this to #command above, otherwise it will call
108
108
  # DSL::Items::Ensure::Item#command which checks for ensure_states
109
- each { |i| i.command!(command, **kwargs) }
109
+ each { |i| i.command!(command, **) }
110
110
  self
111
111
  end
112
112
 
@@ -174,12 +174,6 @@ module OpenHAB
174
174
  GroupItem.extend(Forwardable)
175
175
  GroupItem.def_delegators :members, :equipments, :locations
176
176
 
177
- # This is a marker interface for all semantic tag classes.
178
- # @interface
179
- # @deprecated Since openHAB 4.0, {SemanticTag} is the interface that all tags implement.
180
- # Tags are simple instances, instead of another interface in a hierarchical structure.
181
- Tag = org.openhab.core.semantics.Tag
182
-
183
177
  class << self
184
178
  # @!visibility private
185
179
  def service
@@ -48,8 +48,8 @@ module OpenHAB
48
48
  # @raise [FrozenError] if `update` is true but the existing thing with the same uid
49
49
  # wasn't created by the current provider.
50
50
  #
51
- def build(preferred_provider = nil, update: true, &block)
52
- DSL::Things::Builder.new(preferred_provider, update:).instance_eval(&block)
51
+ def build(preferred_provider = nil, update: true, &)
52
+ DSL::Things::Builder.new(preferred_provider, update:).instance_eval(&)
53
53
  end
54
54
 
55
55
  #
@@ -18,13 +18,7 @@ module OpenHAB
18
18
  remove_method :==
19
19
 
20
20
  extend Forwardable
21
-
22
- # @deprecated OH 4.2 DateTimeType implements Java's Comparable interface in openHAB 4.3
23
- if OpenHAB::Core.version >= OpenHAB::Core::V4_3
24
- include ComparableType
25
- else
26
- include Comparable
27
- end
21
+ include ComparableType
28
22
 
29
23
  class << self
30
24
  #
@@ -43,15 +37,8 @@ module OpenHAB
43
37
  end
44
38
  end
45
39
 
46
- # @deprecated OH 4.2 Just call zoned_date_time(ZoneId.system_default) in OH 4.3
47
- if OpenHAB::Core.version >= OpenHAB::Core::V4_3
48
- def to_zoned_date_time(context = nil) # rubocop:disable Lint/UnusedMethodArgument
49
- zoned_date_time(ZoneId.system_default)
50
- end
51
- else
52
- def to_zoned_date_time(context = nil) # rubocop:disable Lint/UnusedMethodArgument
53
- zoned_date_time
54
- end
40
+ def to_zoned_date_time(context = nil) # rubocop:disable Lint/UnusedMethodArgument
41
+ zoned_date_time(ZoneId.system_default)
55
42
  end
56
43
 
57
44
  # @!method to_zoned_date_time(context = nil)
@@ -93,7 +80,7 @@ module OpenHAB
93
80
  if value.nil?
94
81
  super()
95
82
  return
96
- elsif OpenHAB::Core.version >= OpenHAB::Core::V4_3 && value.respond_to?(:to_instant)
83
+ elsif value.respond_to?(:to_instant)
97
84
  super(value.to_instant)
98
85
  return
99
86
  elsif value.respond_to?(:to_zoned_date_time)
@@ -122,10 +109,7 @@ module OpenHAB
122
109
  def eql?(other)
123
110
  return false unless other.instance_of?(self.class)
124
111
 
125
- # @deprecated OH 4.2 Call compare_to(other).zero? in OH 4.3 to avoid the deprecated getZonedDateTime()
126
- return compare_to(other).zero? if OpenHAB::Core.version >= OpenHAB::Core::V4_3
127
-
128
- zoned_date_time.compare_to(other.zoned_date_time).zero?
112
+ compare_to(other).zero?
129
113
  end
130
114
 
131
115
  #
@@ -141,10 +125,7 @@ module OpenHAB
141
125
  def <=>(other)
142
126
  logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" }
143
127
  if other.is_a?(self.class)
144
- # @deprecated OH 4.2 Call compare_to(other) in OH 4.3 to avoid the deprecated getZonedDateTime()
145
- return compare_to(other) if OpenHAB::Core.version >= OpenHAB::Core::V4_3
146
-
147
- zoned_date_time <=> other.zoned_date_time
128
+ compare_to(other)
148
129
  elsif other.respond_to?(:to_time)
149
130
  to_time <=> other.to_time
150
131
  elsif other.respond_to?(:coerce)
@@ -222,8 +203,7 @@ module OpenHAB
222
203
 
223
204
  # @!visibility private
224
205
  def respond_to_missing?(method, _include_private = false)
225
- # @deprecated OH 4.2 Remove version check when dropping OH 4.2
226
- return true if OpenHAB::Core.version >= OpenHAB::Core::V4_3 && to_instant.respond_to?(method)
206
+ return true if to_instant.respond_to?(method)
227
207
  return true if zoned_date_time.respond_to?(method)
228
208
  return true if ::Time.method_defined?(method.to_sym)
229
209
 
@@ -235,11 +215,7 @@ module OpenHAB
235
215
  # object representing the same instant
236
216
  #
237
217
  def method_missing(method, ...)
238
- # @deprecated OH 4.2 Remove version check when dropping OH 4.2
239
- if OpenHAB::Core.version >= OpenHAB::Core::V4_3 && to_instant.respond_to?(method)
240
- return to_instant.send(method, ...)
241
- end
242
-
218
+ return to_instant.send(method, ...) if to_instant.respond_to?(method)
243
219
  return zoned_date_time.send(method, ...) if zoned_date_time.respond_to?(method)
244
220
  return to_time.send(method, ...) if ::Time.method_defined?(method.to_sym)
245
221
 
@@ -244,8 +244,8 @@ module OpenHAB
244
244
  # @see planckian?
245
245
  # @see https://en.wikipedia.org/wiki/Planckian_locus Planckian Locus
246
246
  # @since openHAB 4.3
247
- def planckian_cct(range: nil, **kwargs)
248
- return unless planckian?(**kwargs)
247
+ def planckian_cct(range: nil, **)
248
+ return unless planckian?(**)
249
249
 
250
250
  range = range.range if range.is_a?(NumberItem)
251
251
  cct = self.cct
data/lib/openhab/core.rb CHANGED
@@ -42,7 +42,7 @@ module OpenHAB
42
42
  @full_version ||= Gem::Version.new(VERSION).freeze
43
43
  end
44
44
 
45
- raise "`openhab-scripting` requires openHAB >= 4.1.0" unless version >= V4_1
45
+ raise "`openhab-scripting` requires openHAB >= 5.0.0" unless version >= V5_0
46
46
 
47
47
  # @return [Integer] Number of seconds to wait between checks for automation manager
48
48
  CHECK_DELAY = 10
@@ -354,12 +354,12 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
354
354
  result
355
355
  end
356
356
 
357
- def shuffle!(*args)
358
- replace(shuffle(*args))
357
+ def shuffle!(*)
358
+ replace(shuffle(*))
359
359
  end
360
360
 
361
- def slice(*args)
362
- self[*args]
361
+ def slice(*)
362
+ self[*]
363
363
  end
364
364
 
365
365
  def slice!(*args)
@@ -95,8 +95,8 @@ module OpenHAB
95
95
  # @param (see GroupItemBuilder#initialize)
96
96
  # @yieldparam [GroupItemBuilder] builder Item for further customization
97
97
  # @return [GroupItem]
98
- def group_item(*args, **kwargs, &block)
99
- item = GroupItemBuilder.new(*args, provider:, **kwargs)
98
+ def group_item(*, **, &block)
99
+ item = GroupItemBuilder.new(*, provider:, **)
100
100
  item.instance_eval(&block) if block
101
101
  result = provider.add(item)
102
102
  item.members.each do |i|
@@ -107,8 +107,8 @@ module OpenHAB
107
107
 
108
108
  private
109
109
 
110
- def item(*args, **kwargs, &block)
111
- item = ItemBuilder.new(*args, provider:, **kwargs)
110
+ def item(*, **, &block)
111
+ item = ItemBuilder.new(*, provider:, **)
112
112
  item.instance_eval(&block) if block
113
113
  r = provider.add(item)
114
114
  return Core::Items::Proxy.new(r) if r.is_a?(Item)
@@ -803,10 +803,10 @@ module OpenHAB
803
803
  # @param thing [Core::Things::ThingUID, Core::Things::Thing, String, nil]
804
804
  # A Thing to be used as the base for the channel for any contained items.
805
805
  # @param (see ItemBuilder#initialize)
806
- def initialize(*args, type: nil, function: nil, thing: nil, **kwargs)
806
+ def initialize(*, type: nil, function: nil, thing: nil, **)
807
807
  raise ArgumentError, "invalid function #{function}" if function && !function.match?(FUNCTION_REGEX)
808
808
 
809
- super(type, *args, **kwargs)
809
+ super(type, *, **)
810
810
  @function = function
811
811
  @members = []
812
812
  @thing = thing
@@ -149,9 +149,9 @@ module OpenHAB
149
149
  # end
150
150
  # end
151
151
  #
152
- def command(command, for: nil, on_expire: nil, only_when_ensured: false, **kwargs, &block)
152
+ def command(command, for: nil, on_expire: nil, only_when_ensured: false, **, &block)
153
153
  duration = binding.local_variable_get(:for)
154
- return super(command, **kwargs) unless duration
154
+ return super(command, **) unless duration
155
155
 
156
156
  on_expire = block if block
157
157
 
@@ -159,10 +159,10 @@ module OpenHAB
159
159
  on_expire ||= default_on_expire(command)
160
160
  if only_when_ensured
161
161
  DSL.ensure_states do
162
- create_timed_command(command, duration:, on_expire:) if super(command, **kwargs)
162
+ create_timed_command(command, duration:, on_expire:) if super(command, **)
163
163
  end
164
164
  else
165
- super(command, **kwargs)
165
+ super(command, **)
166
166
  create_timed_command(command, duration:, on_expire:)
167
167
  end
168
168
  end
@@ -185,7 +185,7 @@ module OpenHAB
185
185
  timed_command_details.timer.reschedule(duration)
186
186
  # disable the cancel rule while we send the new command
187
187
  DSL.rules[timed_command_details.rule_uid].disable
188
- super(command, **kwargs) # This returns nil when "ensured"
188
+ super(command, **) # This returns nil when "ensured"
189
189
  DSL.rules[timed_command_details.rule_uid].enable
190
190
  timed_command_details
191
191
  end
@@ -31,16 +31,16 @@ module OpenHAB
31
31
  # Process rule
32
32
  # @param [Hash] inputs inputs from trigger
33
33
  #
34
- def process(mod:, inputs:, &block)
34
+ def process(mod:, inputs:, &)
35
35
  timer = @timers[inputs["triggeringItem"]&.name]
36
36
  if timer&.active?
37
- process_active_timer(timer, inputs, mod, &block)
37
+ process_active_timer(timer, inputs, mod, &)
38
38
  elsif @conditions.process(mod:, inputs:)
39
39
  logger.trace { "Trigger Guards Matched for #{self}, delaying rule execution" }
40
40
  # Add timer and attach timer to delay object, and also state being tracked to so
41
41
  # timer can be cancelled if state changes
42
42
  # Also another timer should not be created if changed to same value again but instead rescheduled
43
- create_trigger_delay_timer(inputs, mod, &block)
43
+ create_trigger_delay_timer(inputs, mod, &)
44
44
  else
45
45
  logger.trace { "Trigger Guards did not match for #{self}, ignoring trigger." }
46
46
  end
@@ -48,8 +48,8 @@ module OpenHAB
48
48
  # @yield Block executed in the context of a {SitemapBuilder}
49
49
  # @return [SitemapBuilder]
50
50
  # @!visibility public
51
- def sitemap(name, label: nil, icon: nil, &block)
52
- sitemap = SitemapBuilder.new(name, @builder_proxy, label:, icon:, &block)
51
+ def sitemap(name, label: nil, icon: nil, &)
52
+ sitemap = SitemapBuilder.new(name, @builder_proxy, label:, icon:, &)
53
53
  sitemap = sitemap.build
54
54
  if @update && @provider.get(sitemap.uid)
55
55
  @provider.update(sitemap)
@@ -355,8 +355,8 @@ module OpenHAB
355
355
  # @!method initialize(item: nil, label: nil, icon: nil, static_icon: nil, mappings: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil)
356
356
  # @param mappings [Hash, Array, nil] Mappings from command to label (see {SwitchBuilder#mappings})
357
357
  # @!visibility private
358
- def initialize(type, builder_proxy, mappings: nil, **kwargs, &block)
359
- super(type, builder_proxy, **kwargs, &block)
358
+ def initialize(type, builder_proxy, mappings: nil, **, &)
359
+ super(type, builder_proxy, **, &)
360
360
 
361
361
  @mappings = mappings
362
362
  end
@@ -370,8 +370,7 @@ module OpenHAB
370
370
  mapping.cmd = cmd.to_s
371
371
  mapping.release_cmd = release_cmd.to_s unless release_cmd.nil?
372
372
  mapping.label = label&.to_s || cmd.to_s
373
- # @deprecated OH 4.1 the if check is not needed in OH4.1+
374
- mapping.icon = icon if icon
373
+ mapping.icon = icon
375
374
  widget.mappings.add(mapping)
376
375
  end
377
376
  widget
@@ -400,8 +399,8 @@ module OpenHAB
400
399
  # @param range [Range, nil] Allowed range of the value (see {SetpointBuilder#range})
401
400
  # @param step [Numeric,nil] How far the value will change with each button press (see {SetpointBuilder#step})
402
401
  # @!visibility private
403
- def initialize(type, builder_proxy, range: nil, step: nil, **kwargs, &block)
404
- super(type, builder_proxy, **kwargs, &block)
402
+ def initialize(type, builder_proxy, range: nil, step: nil, **, &)
403
+ super(type, builder_proxy, **, &)
405
404
 
406
405
  @range = range
407
406
  @step = step
@@ -441,8 +440,8 @@ module OpenHAB
441
440
  # @param release_only [true, false, nil]
442
441
  # Only send the command when the slider is released (see {SliderBuilder#release_only=})
443
442
  # @!visibility private
444
- def initialize(type, builder_proxy, switch: nil, frequency: nil, release_only: nil, **kwargs, &block)
445
- super(type, builder_proxy, **kwargs, &block)
443
+ def initialize(type, builder_proxy, switch: nil, frequency: nil, release_only: nil, **, &)
444
+ super(type, builder_proxy, **, &)
446
445
 
447
446
  @switch = switch
448
447
  @frequency = frequency
@@ -464,8 +463,7 @@ module OpenHAB
464
463
  widget = super
465
464
  widget.switch_enabled = switch? unless @switch.nil?
466
465
  widget.send_frequency = (frequency * 1000).to_i if frequency
467
- # @deprecated OH 4.1 remove the version check when dropping OH 4.1 support
468
- widget.release_only = release_only? if OpenHAB::Core.version >= OpenHAB::Core::V4_2 && !@release_only.nil?
466
+ widget.release_only = release_only? unless @release_only.nil?
469
467
  widget
470
468
  end
471
469
  end
@@ -487,8 +485,8 @@ module OpenHAB
487
485
  # @param [String, nil] url (see {VideoBuilder#url})
488
486
  # @param [:mjpeg, :hls, nil] encoding (see {VideoBuilder#encoding})
489
487
  # @!visibility private
490
- def initialize(type, builder_proxy, url: nil, encoding: nil, **kwargs, &block)
491
- super(type, builder_proxy, **kwargs, &block)
488
+ def initialize(type, builder_proxy, url: nil, encoding: nil, **, &)
489
+ super(type, builder_proxy, **, &)
492
490
 
493
491
  @url = url
494
492
  self.encoding = encoding
@@ -563,9 +561,9 @@ module OpenHAB
563
561
  legend: nil,
564
562
  group: nil,
565
563
  y_axis_pattern: nil,
566
- **kwargs,
567
- &block)
568
- super(type, builder_proxy, **kwargs, &block)
564
+ **,
565
+ &)
566
+ super(type, builder_proxy, **, &)
569
567
 
570
568
  @service = service
571
569
  self.refresh = refresh
@@ -615,8 +613,8 @@ module OpenHAB
615
613
  # @!method initialize(item: nil, label: nil, icon: nil, static_icon: nil, height: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil)
616
614
  # @param height [Integer] The number of element rows to fill (see {DefaultBuilder#height})
617
615
  # @!visibility private
618
- def initialize(type, builder_proxy, height: nil, **kwargs, &block)
619
- super(type, builder_proxy, **kwargs, &block)
616
+ def initialize(type, builder_proxy, height: nil, **, &)
617
+ super(type, builder_proxy, **, &)
620
618
 
621
619
  @height = height
622
620
  end
@@ -640,8 +638,8 @@ module OpenHAB
640
638
  # @!method initialize(item: nil, label: nil, icon: nil, static_icon: nil, url: nil, height: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil)
641
639
  # @param url [String, nil] (see {WebviewBuilder#url})
642
640
  # @!visibility private
643
- def initialize(type, builder_proxy, url: nil, **kwargs, &block)
644
- super(type, builder_proxy, **kwargs, &block)
641
+ def initialize(type, builder_proxy, url: nil, **, &)
642
+ super(type, builder_proxy, **, &)
645
643
 
646
644
  @url = url
647
645
  end
@@ -666,8 +664,8 @@ module OpenHAB
666
664
  # @!method initialize(item: nil, label: nil, icon: nil, static_icon: nil, frequency: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil)
667
665
  # @param frequency [Numeric, nil] How often to send requests (see {ColorpickerBuilder#frequency})
668
666
  # @!visibility private
669
- def initialize(type, builder_proxy, frequency: nil, **kwargs, &block)
670
- super(type, builder_proxy, **kwargs, &block)
667
+ def initialize(type, builder_proxy, frequency: nil, **, &)
668
+ super(type, builder_proxy, **, &)
671
669
 
672
670
  @frequency = frequency
673
671
  end
@@ -692,8 +690,8 @@ module OpenHAB
692
690
  # @!method initialize(item: nil, label: nil, icon: nil, static_icon: nil, range: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil)
693
691
  # @param range [Range, nil] Allowed range of the value (see {ColortemperaturepickerBuilder#range})
694
692
  # @!visibility private
695
- def initialize(type, builder_proxy, range: nil, **kwargs, &block)
696
- super(type, builder_proxy, **kwargs, &block)
693
+ def initialize(type, builder_proxy, range: nil, **, &)
694
+ super(type, builder_proxy, **, &)
697
695
 
698
696
  @range = range
699
697
  end
@@ -729,8 +727,8 @@ module OpenHAB
729
727
  # @param [:text, :number, :date, :time, :datetime, nil] hint
730
728
  # Gives a hint to the user interface to use a widget adapted to a specific use (see {InputBuilder#hint})
731
729
  # @!visibility private
732
- def initialize(type, builder_proxy, hint: nil, **kwargs, &block)
733
- super(type, builder_proxy, **kwargs, &block)
730
+ def initialize(type, builder_proxy, hint: nil, **, &)
731
+ super(type, builder_proxy, **, &)
734
732
 
735
733
  self.hint = hint
736
734
  end
@@ -798,9 +796,9 @@ module OpenHAB
798
796
  click:,
799
797
  release: nil,
800
798
  stateless: nil,
801
- **kwargs,
802
- &block)
803
- super(:button, builder_proxy, **kwargs, &block)
799
+ **,
800
+ &)
801
+ super(:button, builder_proxy, **, &)
804
802
 
805
803
  @row = row
806
804
  @column = column
@@ -816,24 +814,12 @@ module OpenHAB
816
814
 
817
815
  # @!visibility private
818
816
  def build
819
- if Core.version >= Core::V4_2
820
- super.tap do |widget|
821
- widget.row = row
822
- widget.column = column
823
- widget.cmd = click.to_s
824
- widget.release_cmd = release.to_s unless release.nil?
825
- widget.stateless = stateless? unless @stateless.nil?
826
- end
827
- else
828
- # @deprecated OH 4.1
829
- # in OH 4.1, the button is a property of the Buttongrid, not a widget
830
- SitemapBuilder.factory.create_button.tap do |button|
831
- button.row = row
832
- button.column = column
833
- button.cmd = click.to_s
834
- button.label = label
835
- button.icon = icon if icon
836
- end
817
+ super.tap do |widget|
818
+ widget.row = row
819
+ widget.column = column
820
+ widget.cmd = click.to_s
821
+ widget.release_cmd = release.to_s unless release.nil?
822
+ widget.stateless = stateless? unless @stateless.nil?
837
823
  end
838
824
  end
839
825
  end
@@ -1220,8 +1206,8 @@ module OpenHAB
1220
1206
  # @param url [String, nil] The URL for the image (see {ImageBuilder#url})
1221
1207
  # @param refresh [Numeric, nil] How often to refresh the image (see {ImageBuilder#refresh})
1222
1208
  # @!visibility private
1223
- def initialize(type, builder_proxy, url: nil, refresh: nil, **kwargs, &block)
1224
- super(type, builder_proxy, **kwargs, &block)
1209
+ def initialize(type, builder_proxy, url: nil, refresh: nil, **, &)
1210
+ super(type, builder_proxy, **, &)
1225
1211
 
1226
1212
  @url = url
1227
1213
  @refresh = refresh
@@ -1250,17 +1236,6 @@ module OpenHAB
1250
1236
  REQUIRED_BUTTON_ARGS = %i[row column click].freeze
1251
1237
  private_constant :REQUIRED_BUTTON_ARGS
1252
1238
 
1253
- # @deprecated OH 4.1 in OH 4.1, Buttongrid is not a LinkableWidget.
1254
- # Pretend that the buttons property is its children so we can add to it in LinkableWidgetBuilder#build
1255
- if (Core::V4_1...Core::V4_2).cover?(Core.version)
1256
- java_import org.openhab.core.model.sitemap.sitemap.Buttongrid
1257
- module Buttongrid
1258
- def children
1259
- buttons
1260
- end
1261
- end
1262
- end
1263
-
1264
1239
  # (see WidgetBuilder#initialize)
1265
1240
  # @!method initialize(item: nil, label: nil, icon: nil, static_icon: nil, buttons: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil)
1266
1241
  # @param [Array<Array<int, int, Command, String, String>>] buttons An array of buttons to display.
@@ -1315,8 +1290,8 @@ module OpenHAB
1315
1290
  #
1316
1291
  # @see https://www.openhab.org/docs/ui/sitemaps.html#element-type-buttongrid
1317
1292
  # @!visibility private
1318
- def initialize(type, builder_proxy, buttons: [], **kwargs, &block)
1319
- super(type, builder_proxy, **kwargs, &block)
1293
+ def initialize(type, builder_proxy, buttons: [], **, &)
1294
+ super(type, builder_proxy, **, &)
1320
1295
 
1321
1296
  # Put the buttons given in the constructor before those added in the block
1322
1297
  # We can't do this before calling the super constructor because `children` is initialized there
@@ -1423,7 +1398,7 @@ module OpenHAB
1423
1398
  # end
1424
1399
  # end
1425
1400
  #
1426
- def button(row = nil, column = nil, click = nil, label = nil, icon = nil, **kwargs, &block)
1401
+ def button(row = nil, column = nil, click = nil, label = nil, icon = nil, **kwargs, &)
1427
1402
  args = [row, column, click, label, icon].compact
1428
1403
 
1429
1404
  args = args.first if args.first.is_a?(Array)
@@ -1439,7 +1414,7 @@ module OpenHAB
1439
1414
  kwargs[:item] ||= item if item # default to the buttongrid's item
1440
1415
  kwargs[:label] ||= kwargs[:click].to_s
1441
1416
 
1442
- ButtonBuilder.new(@builder_proxy, **kwargs, &block).tap do |b|
1417
+ ButtonBuilder.new(@builder_proxy, **kwargs, &).tap do |b|
1443
1418
  children << b
1444
1419
  end
1445
1420
  end
@@ -89,8 +89,8 @@ module OpenHAB
89
89
 
90
90
  private
91
91
 
92
- def build(klass, *args, **kwargs, &block)
93
- builder = klass.new(*args, **kwargs)
92
+ def build(klass, *, **, &block)
93
+ builder = klass.new(*, **)
94
94
  builder.parent_builder = self if builder.respond_to?(:parent_builder=)
95
95
  builder.instance_eval(&block) if block
96
96
  thing = builder.build
@@ -227,8 +227,8 @@ module OpenHAB
227
227
  # Add an explicitly configured channel to this item
228
228
  # @see ChannelBuilder#initialize
229
229
  # @return [Core::Things::Channel]
230
- def channel(*args, **kwargs, &block)
231
- channel = ChannelBuilder.new(*args, thing: self, **kwargs)
230
+ def channel(*, **, &block)
231
+ channel = ChannelBuilder.new(*, thing: self, **)
232
232
  channel.instance_eval(&block) if block
233
233
  channel.build.tap { |c| @channels << c }
234
234
  end
@@ -287,14 +287,14 @@ module OpenHAB
287
287
 
288
288
  # Create a new Bridge with this Bridge as its Bridge
289
289
  # @see BridgeBuilder#initialize
290
- def bridge(*args, **kwargs, &)
291
- parent_builder.bridge(*args, bridge: self, **kwargs, &)
290
+ def bridge(*, **, &)
291
+ parent_builder.bridge(*, bridge: self, **, &)
292
292
  end
293
293
 
294
294
  # Create a new Thing with this Bridge as its Bridge
295
295
  # @see ThingBuilder#initialize
296
- def thing(*args, **kwargs, &)
297
- parent_builder.thing(*args, bridge: self, **kwargs, &)
296
+ def thing(*, **, &)
297
+ parent_builder.thing(*, bridge: self, **, &)
298
298
  end
299
299
  end
300
300
 
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "set"
4
3
  require "singleton"
5
4
 
6
5
  module OpenHAB
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.45.0"
7
+ VERSION = "5.46.0"
8
8
  end
9
9
  end
data/lib/openhab/dsl.rb CHANGED
@@ -86,39 +86,39 @@ module OpenHAB
86
86
  # @!group Rule Creation
87
87
 
88
88
  # (see Rules::Builder#rule)
89
- def rule(name = nil, id: nil, **kwargs, &block)
90
- rules.build { rule(name, id:, **kwargs, &block) }
89
+ def rule(name = nil, id: nil, **, &)
90
+ rules.build { rule(name, id:, **, &) }
91
91
  end
92
92
 
93
93
  # Creates a rule that will remove existing rules with the same id, even when the id has been inferred.
94
94
  # @see rule
95
- def rule!(name = nil, id: nil, **kwargs, &block)
96
- rules.build { rule(name, id:, replace: true, **kwargs, &block) }
95
+ def rule!(name = nil, id: nil, **, &)
96
+ rules.build { rule(name, id:, replace: true, **, &) }
97
97
  end
98
98
 
99
99
  # (see Rules::Builder#scene)
100
- def scene(name = nil, description: nil, id: nil, tag: nil, tags: nil, **kwargs, &block)
101
- rules.build { scene(name, description:, id:, tag:, tags:, **kwargs, &block) }
100
+ def scene(name = nil, description: nil, id: nil, tag: nil, tags: nil, **, &)
101
+ rules.build { scene(name, description:, id:, tag:, tags:, **, &) }
102
102
  end
103
103
 
104
104
  # Creates a scene that will remove existing rules/scenes with the same id, even when the id has been inferred.
105
105
  # @see scene
106
- def scene!(name = nil, description: nil, id: nil, tag: nil, tags: nil, **kwargs, &block)
106
+ def scene!(name = nil, description: nil, id: nil, tag: nil, tags: nil, **, &)
107
107
  rules.build do
108
- scene(name, description:, id:, tag:, tags:, replace: true, **kwargs, &block)
108
+ scene(name, description:, id:, tag:, tags:, replace: true, **, &)
109
109
  end
110
110
  end
111
111
 
112
112
  # (see Rules::Builder#script)
113
- def script(name = nil, description: nil, id: nil, tag: nil, tags: nil, **kwargs, &block)
114
- rules.build { script(name, description:, id:, tag:, tags:, **kwargs, &block) }
113
+ def script(name = nil, description: nil, id: nil, tag: nil, tags: nil, **, &)
114
+ rules.build { script(name, description:, id:, tag:, tags:, **, &) }
115
115
  end
116
116
 
117
117
  # Creates a script that will remove existing rules/scripts with the same id, even when the id has been inferred.
118
118
  # @see script
119
- def script!(name = nil, description: nil, id: nil, tag: nil, tags: nil, **kwargs, &block)
119
+ def script!(name = nil, description: nil, id: nil, tag: nil, tags: nil, **, &)
120
120
  rules.build do
121
- script(name, description:, id:, tag:, tags:, replace: true, **kwargs, &block)
121
+ script(name, description:, id:, tag:, tags:, replace: true, **, &)
122
122
  end
123
123
  end
124
124
 
@@ -519,7 +519,7 @@ module OpenHAB
519
519
  #
520
520
  # @param (see Rules::BuilderDSL#debounce_for)
521
521
  # @param [Object] id ID to associate with this call.
522
- # @param [Block] block The block to be debounced.
522
+ # @yield The block to be debounced.
523
523
  #
524
524
  # @return [void]
525
525
  #
@@ -536,9 +536,9 @@ module OpenHAB
536
536
  #
537
537
  # @see Rules::BuilderDSL#debounce_for Rule builder's debounce_for for a detailed description
538
538
  #
539
- def debounce_for(debounce_time, id: nil, &block)
539
+ def debounce_for(debounce_time, id: nil, &)
540
540
  idle_time = debounce_time.is_a?(Range) ? debounce_time.begin : debounce_time
541
- debounce(for: debounce_time, idle_time:, id:, &block)
541
+ debounce(for: debounce_time, idle_time:, id:, &)
542
542
  end
543
543
 
544
544
  #
@@ -562,15 +562,15 @@ module OpenHAB
562
562
  #
563
563
  # @param (see Rules::BuilderDSL#throttle_for)
564
564
  # @param [Object] id ID to associate with this call.
565
- # @param [Block] block The block to be throttled.
565
+ # @yield The block to be throttled.
566
566
  #
567
567
  # @return [void]
568
568
  #
569
569
  # @see Rules::BuilderDSL#debounce_for Rule builder's debounce_for for a detailed description
570
570
  # @see Rules::BuilderDSL#throttle_for
571
571
  #
572
- def throttle_for(duration, id: nil, &block)
573
- debounce(for: duration, id:, &block)
572
+ def throttle_for(duration, id: nil, &)
573
+ debounce(for: duration, id:, &)
574
574
  end
575
575
 
576
576
  # (see Core::Actions::Transformation.transform)
@@ -587,7 +587,7 @@ module OpenHAB
587
587
  #
588
588
  # @param (see Rules::BuilderDSL#only_every)
589
589
  # @param [Object] id ID to associate with this call.
590
- # @param [Block] block The block to be throttled.
590
+ # @yield The block to be throttled.
591
591
  #
592
592
  # @return [void]
593
593
  #
@@ -599,9 +599,9 @@ module OpenHAB
599
599
  # @see Rules::BuilderDSL#debounce_for Rule builder's debounce_for for a detailed description
600
600
  # @see Rules::BuilderDSL#only_every
601
601
  #
602
- def only_every(interval, id: nil, &block)
602
+ def only_every(interval, id: nil, &)
603
603
  interval = 1.send(interval) if %i[second minute hour day].include?(interval)
604
- debounce(for: interval, leading: true, id:, &block)
604
+ debounce(for: interval, leading: true, id:, &)
605
605
  end
606
606
 
607
607
  #
@@ -280,8 +280,6 @@ module OpenHAB
280
280
  OSGi.register_service(new_ast, *services, bundle: ast_bundle)
281
281
  end
282
282
  end
283
- rescue NameError
284
- # @deprecated OH 4.0
285
283
  end
286
284
 
287
285
  # RSpec additions
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "fileutils"
4
- require "set"
5
4
  require "shellwords"
6
5
  require "time"
7
6
 
@@ -160,11 +159,11 @@ module OpenHAB
160
159
  :karafEtc,
161
160
  :defaultStartLevel
162
161
  klass.class_eval do
163
- def send_private(method_name, *args)
162
+ def send_private(method_name, *)
164
163
  method_name = method_name.to_s
165
164
  method = self.class.java_class.declared_methods.find { |m| m.name == method_name }
166
165
  method.accessible = true
167
- method.invoke(self, *args)
166
+ method.invoke(self, *)
168
167
  end
169
168
 
170
169
  def launch_simple
@@ -99,9 +99,9 @@ module OpenHAB
99
99
  # @!visibility private
100
100
  module ClassMethods
101
101
  # @!visibility private
102
- def new(*args, **kwargs)
102
+ def new(*, **)
103
103
  return super if self == Timer
104
- return Timer.new(*args, **kwargs) if Timer.mock_timers?
104
+ return Timer.new(*, **) if Timer.mock_timers?
105
105
 
106
106
  super
107
107
  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.45.0
4
+ version: 5.46.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
@@ -15,16 +15,22 @@ dependencies:
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '2.2'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '5.0'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: '2.2'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: marcel
30
36
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +65,7 @@ dependencies:
59
65
  requirements:
60
66
  - - ">="
61
67
  - !ruby/object:Gem::Version
62
- version: 4.1.0
68
+ version: 5.0.0
63
69
  - - "<"
64
70
  - !ruby/object:Gem::Version
65
71
  version: '5.3'
@@ -69,7 +75,7 @@ dependencies:
69
75
  requirements:
70
76
  - - ">="
71
77
  - !ruby/object:Gem::Version
72
- version: 4.1.0
78
+ version: 5.0.0
73
79
  - - "<"
74
80
  - !ruby/object:Gem::Version
75
81
  version: '5.3'
@@ -341,14 +347,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
341
347
  requirements:
342
348
  - - ">="
343
349
  - !ruby/object:Gem::Version
344
- version: 3.1.4
350
+ version: 3.4.2
345
351
  required_rubygems_version: !ruby/object:Gem::Requirement
346
352
  requirements:
347
353
  - - ">="
348
354
  - !ruby/object:Gem::Version
349
355
  version: '0'
350
356
  requirements: []
351
- rubygems_version: 3.6.9
357
+ rubygems_version: 4.0.3
352
358
  specification_version: 4
353
359
  summary: JRuby Helper Libraries for openHAB Scripting
354
360
  test_files: []