openhab-scripting 5.27.1 → 5.27.2

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openhab/core/actions.rb +1 -1
  3. data/lib/openhab/core/items/generic_item.rb +1 -1
  4. data/lib/openhab/core/items/image_item.rb +1 -1
  5. data/lib/openhab/core/items/metadata/namespace_hash.rb +1 -1
  6. data/lib/openhab/core/items/semantics.rb +1 -1
  7. data/lib/openhab/core/items.rb +4 -4
  8. data/lib/openhab/core/profile_factory.rb +3 -1
  9. data/lib/openhab/core/script_handling.rb +1 -1
  10. data/lib/openhab/core/things/thing.rb +1 -1
  11. data/lib/openhab/core/types/date_time_type.rb +2 -2
  12. data/lib/openhab/core/types/decimal_type.rb +2 -2
  13. data/lib/openhab/core/types/hsb_type.rb +2 -2
  14. data/lib/openhab/core/types/point_type.rb +1 -1
  15. data/lib/openhab/core/types/quantity_type.rb +7 -7
  16. data/lib/openhab/core/types/string_type.rb +2 -2
  17. data/lib/openhab/core/types.rb +1 -1
  18. data/lib/openhab/core.rb +1 -1
  19. data/lib/openhab/core_ext/java/month_day.rb +1 -1
  20. data/lib/openhab/dsl/rules/automation_rule.rb +2 -2
  21. data/lib/openhab/dsl/rules/guard.rb +1 -1
  22. data/lib/openhab/dsl/rules/rule_triggers.rb +2 -2
  23. data/lib/openhab/dsl/rules/triggers/conditions/duration.rb +10 -8
  24. data/lib/openhab/dsl/rules/triggers/conditions/generic.rb +1 -1
  25. data/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb +2 -2
  26. data/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb +1 -1
  27. data/lib/openhab/dsl/timer_manager.rb +3 -3
  28. data/lib/openhab/dsl/version.rb +1 -1
  29. data/lib/openhab/dsl.rb +2 -2
  30. data/lib/openhab/rspec/mocks/event_admin.rb +2 -1
  31. data/lib/openhab/rspec/openhab/core/actions.rb +9 -9
  32. data/lib/openhab/rspec/suspend_rules.rb +1 -1
  33. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e0abb8ef69de3f3ee26fa45213d2d9afa55f4b4816cde92ab6dd68ea9f95ad5
4
- data.tar.gz: bcb8c93446e87d55b2d07cfa24762b684e313f2f546c77bfa1b946c227061a00
3
+ metadata.gz: 55919e4e10099bb160e0f64578c398caef457c330e88df280a20ed20ffec6310
4
+ data.tar.gz: 2052d4bcd4dc3bcd7b2be5c4bb7b995fcaebc7101b93e24fd2db0e849b80ff36
5
5
  SHA512:
6
- metadata.gz: ec47bcf9491772968a8f6ca7ac5853ed403986d75eb1ae69f92f43ada70af126552abec30af4a7d02bd5cf63daaf4ce5d7b9b86433899f1161e72e5807f6c06e
7
- data.tar.gz: ad58da972b4b1bbf34e4a9e0af7bc56f8debec4126ce64e1c8133b6d1dd10d584c3c7344bb9740be56977f5c948a6ccb6db055a0179fd4fb84d77d53e88e36e1
6
+ metadata.gz: 1c39a9d29033bf7844d1f5666f57be9ae99ae595a8d5f85e4464b6077c0171e4f4e9e19d933f17a0e190c2081dae57dc29136bb4c3e295f2d83e8e1d88374ce1
7
+ data.tar.gz: 5a828c34365b2d8fcef74c46fe19e94fc30dbb0c4fd17fcef7bc717a95ccb2e0b51cfadf701447d9a97c58057baebe77d8186811886479112096b46e16749a28
@@ -37,7 +37,7 @@ module OpenHAB
37
37
  else
38
38
  (java_import action_class.ruby_class).first
39
39
  end
40
- logger.trace("Loaded ACTION: #{action_class}")
40
+ logger.trace { "Loaded ACTION: #{action_class}" }
41
41
  Object.const_set(module_name, action)
42
42
  end
43
43
 
@@ -276,7 +276,7 @@ module OpenHAB
276
276
  raise FrozenError, "Cannot modify item #{name} from provider #{provider.inspect}." unless force
277
277
 
278
278
  provider = nil
279
- logger.debug("Forcing modifications to non-managed item #{name}")
279
+ logger.debug { "Forcing modifications to non-managed item #{name}" }
280
280
  end
281
281
  @modified = false
282
282
  @modifying = true
@@ -55,7 +55,7 @@ module OpenHAB
55
55
  #
56
56
  #
57
57
  def update_from_url(uri)
58
- logger.trace("Downloading image from #{uri}")
58
+ logger.trace { "Downloading image from #{uri}" }
59
59
  response = Net::HTTP.get_response(URI(uri))
60
60
  mime_type = response["content-type"]
61
61
  bytes = response.body
@@ -73,7 +73,7 @@ module OpenHAB
73
73
  raise ArgumentError, "Wrong number of arguments (given #{default_value.length + 1}, expected 1..2)"
74
74
  end
75
75
 
76
- logger.trace("Getting metadata for item: #{@item_name}, namespace '#{key}'")
76
+ logger.trace { "Getting metadata for item: #{@item_name}, namespace '#{key}'" }
77
77
  if (m = Provider.registry.get(MetadataKey.new(key, @item_name)))
78
78
  Hash.new(m)
79
79
  elsif block
@@ -251,7 +251,7 @@ module OpenHAB
251
251
  #
252
252
  # @!visibility private
253
253
  def const_missing(sym)
254
- logger.trace("const missing, performing Semantics Lookup for: #{sym}")
254
+ logger.trace { "const missing, performing Semantics Lookup for: #{sym}" }
255
255
  lookup(sym)&.tap { |tag| const_set(sym, tag) } || super
256
256
  end
257
257
  end
@@ -44,7 +44,7 @@ module OpenHAB
44
44
  _command_predicate, state_predicate = Types::PREDICATE_ALIASES[state.to_s]
45
45
  next if klass.instance_methods.include?(state_predicate)
46
46
 
47
- logger.trace("Defining #{klass}##{state_predicate} for #{state}")
47
+ logger.trace { "Defining #{klass}##{state_predicate} for #{state}" }
48
48
  klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
49
49
  def #{state_predicate} # def on?
50
50
  raw_state.as(#{state.class.java_class.simple_name}).equal?(#{state}) # raw_state.as(OnOffType) == ON
@@ -61,7 +61,7 @@ module OpenHAB
61
61
  next if klass.instance_methods.include?(command)
62
62
 
63
63
  if value.is_a?(Types::State)
64
- logger.trace("Defining #{klass}/Enumerable##{command}/#{command}! for #{value}")
64
+ logger.trace { "Defining #{klass}/Enumerable##{command}/#{command}! for #{value}" }
65
65
 
66
66
  klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
67
67
  ruby2_keywords def #{command}(*args, &block) # ruby2_keywords def on(*args, &block)
@@ -83,7 +83,7 @@ module OpenHAB
83
83
  end # end
84
84
  RUBY
85
85
  else
86
- logger.trace("Defining #{klass}/Enumerable##{command} for #{value}")
86
+ logger.trace { "Defining #{klass}/Enumerable##{command} for #{value}" }
87
87
 
88
88
  klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
89
89
  ruby2_keywords def #{command}(*args, &block) # ruby2_keywords def refresh(*args, &block)
@@ -98,7 +98,7 @@ module OpenHAB
98
98
  RUBY
99
99
  end
100
100
 
101
- logger.trace("Defining ItemCommandEvent##{command}? for #{value}")
101
+ logger.trace { "Defining ItemCommandEvent##{command}? for #{value}" }
102
102
  Events::ItemCommandEvent.class_eval <<~RUBY, __FILE__, __LINE__ + 1
103
103
  def #{command}? # def refresh?
104
104
  command.as(#{value.class.java_class.simple_name}).equal?(#{value}) # command.as(RefreshType).equal?(REFRESH)
@@ -86,7 +86,9 @@ module OpenHAB
86
86
  private
87
87
 
88
88
  def process_event(event, **params)
89
- logger.trace("Handling event #{event.inspect} in profile #{@uid} with param #{params.values.first.inspect}.")
89
+ logger.trace do
90
+ "Handling event #{event.inspect} in profile #{@uid} with param #{params.values.first.inspect}."
91
+ end
90
92
 
91
93
  params[:callback] = @callback
92
94
  params[:context] = @context
@@ -119,7 +119,7 @@ module OpenHAB
119
119
  # Executed when openHAB loads a script file
120
120
  #
121
121
  def scriptLoaded(filename) # rubocop:disable Naming/MethodName method name dictated by openHAB
122
- logger.trace("Script loaded: #{filename}")
122
+ logger.trace { "Script loaded: #{filename}" }
123
123
  ScriptHandlingCallbacks.script_loaded_hooks.each do |hook|
124
124
  hook.call
125
125
  rescue => e
@@ -256,7 +256,7 @@ module OpenHAB
256
256
 
257
257
  # @!visibility private
258
258
  def respond_to_missing?(method_name, _include_private = false)
259
- logger.trace("Checking if Thing #{uid} supports #{method_name} action")
259
+ logger.trace { "Checking if Thing #{uid} supports #{method_name} action" }
260
260
  return true if actions.respond_to?(method_name)
261
261
 
262
262
  super
@@ -113,7 +113,7 @@ module OpenHAB
113
113
  # `nil` is returned if the two values are incomparable.
114
114
  #
115
115
  def <=>(other)
116
- logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})")
116
+ logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" }
117
117
  if other.is_a?(self.class)
118
118
  zoned_date_time <=> other.zoned_date_time
119
119
  elsif other.respond_to?(:to_time)
@@ -135,7 +135,7 @@ module OpenHAB
135
135
  # @return [[DateTimeType, DateTimeType], nil]
136
136
  #
137
137
  def coerce(other)
138
- logger.trace("Coercing #{self} as a request from #{other.class}")
138
+ logger.trace { "Coercing #{self} as a request from #{other.class}" }
139
139
  return [other, zoned_date_time] if other.respond_to?(:to_zoned_date_time)
140
140
 
141
141
  [DateTimeType.new(other), self] if other.respond_to?(:to_time)
@@ -91,7 +91,7 @@ module OpenHAB
91
91
  # `nil` is returned if the two values are incomparable.
92
92
  #
93
93
  def <=>(other)
94
- logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})")
94
+ logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" }
95
95
  if other.is_a?(QuantityType) || other.is_a?(HSBType)
96
96
  (other <=> self)&.-@
97
97
  elsif other.is_a?(self.class)
@@ -115,7 +115,7 @@ module OpenHAB
115
115
  # @return [Array<(DecimalType, DecimalType)>, nil]
116
116
  #
117
117
  def coerce(other)
118
- logger.trace("Coercing #{self} as a request from #{other.class}")
118
+ logger.trace { "Coercing #{self} as a request from #{other.class}" }
119
119
  return unless other.respond_to?(:to_d)
120
120
 
121
121
  [self.class.new(other.to_d), self]
@@ -65,7 +65,7 @@ module OpenHAB
65
65
  # in this case, HTML hex format for rgb
66
66
  if (match = value.match(/^#(\h{2})(\h{2})(\h{2})$/))
67
67
  rgb = match.to_a[1..3].map { |v| v.to_i(16) }
68
- logger.trace("creating from rgb #{rgb.inspect}")
68
+ logger.trace { "creating from rgb #{rgb.inspect}" }
69
69
  return from_rgb(*rgb)
70
70
  end
71
71
  end
@@ -110,7 +110,7 @@ module OpenHAB
110
110
  # `nil` is returned if the two values are incomparable.
111
111
  #
112
112
  def <=>(other)
113
- logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})")
113
+ logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" }
114
114
  if other.is_a?(HSBType)
115
115
  [brightness, hue, saturation] <=> [other.brightness, other.hue, other.saturation]
116
116
  else
@@ -103,7 +103,7 @@ module OpenHAB
103
103
  #
104
104
  # @return [QuantityType]
105
105
  def distance_from(other)
106
- logger.trace("(#{self}).distance_from(#{other} (#{other.class})")
106
+ logger.trace { "(#{self}).distance_from(#{other} (#{other.class})" }
107
107
  raise TypeError, "#{other.class} can't be coerced into #{self.class}" unless other.is_a?(PointType)
108
108
 
109
109
  QuantityType.new(raw_distance_from(other), SIUnits::METRE)
@@ -132,7 +132,7 @@ module OpenHAB
132
132
  # `nil` is returned if the two values are incomparable.
133
133
  #
134
134
  def <=>(other)
135
- logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})")
135
+ logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" }
136
136
  case other
137
137
  when self.class
138
138
  return unitize(other.unit).compare_to(other) if unit == Units::ONE
@@ -161,7 +161,7 @@ module OpenHAB
161
161
  #
162
162
  # @return [Array<(QuantityType, QuantityType)>, nil]
163
163
  def coerce(other)
164
- logger.trace("Coercing #{self} as a request from #{other.class}")
164
+ logger.trace { "Coercing #{self} as a request from #{other.class}" }
165
165
  return unless other.respond_to?(:to_d)
166
166
 
167
167
  [QuantityType.new(other.to_d.to_java, Units::ONE), self]
@@ -178,7 +178,7 @@ module OpenHAB
178
178
 
179
179
  class_eval( # rubocop:disable Style/DocumentDynamicEvalDefinition https://github.com/rubocop/rubocop/issues/10179
180
180
  # def +(other)
181
- # logger.trace("#{self} + #{other} (#{other.class})")
181
+ # logger.trace { "#{self} + #{other} (#{other.class})" }
182
182
  # other = other.state if other.is_a?(Core::Items::Persistence::PersistedState)
183
183
  # if other.is_a?(QuantityType)
184
184
  # add_quantity(other)
@@ -203,7 +203,7 @@ module OpenHAB
203
203
  # end
204
204
  <<~RUBY, __FILE__, __LINE__ + 1
205
205
  def #{ruby_op}(other)
206
- logger.trace("\#{self} #{ruby_op} \#{other} (\#{other.class})")
206
+ logger.trace { "\#{self} #{ruby_op} \#{other} (\#{other.class})" }
207
207
  other = other.state if other.is_a?(Core::Items::Persistence::PersistedState)
208
208
  if other.is_a?(QuantityType)
209
209
  #{java_op}_quantity(other)
@@ -236,7 +236,7 @@ module OpenHAB
236
236
  }.each do |java_op, ruby_op|
237
237
  class_eval( # rubocop:disable Style/DocumentDynamicEvalDefinition https://github.com/rubocop/rubocop/issues/10179
238
238
  # def *(other)
239
- # logger.trace("#{self} * #{other} (#{other.class})")
239
+ # logger.trace { "#{self} * #{other} (#{other.class})" }
240
240
  # other = other.state if other.is_a?(Core::Items::Persistence::PersistedState)
241
241
  # if other.is_a?(QuantityType)
242
242
  # multiply_quantity(other)
@@ -254,7 +254,7 @@ module OpenHAB
254
254
  # end
255
255
  <<~RUBY, __FILE__, __LINE__ + 1
256
256
  def #{ruby_op}(other)
257
- logger.trace("\#{self} #{ruby_op} \#{other} (\#{other.class})")
257
+ logger.trace { "\#{self} #{ruby_op} \#{other} (\#{other.class})" }
258
258
  other = other.state if other.is_a?(Core::Items::Persistence::PersistedState)
259
259
  if other.is_a?(QuantityType)
260
260
  #{java_op}_quantity(other).unitize
@@ -279,7 +279,7 @@ module OpenHAB
279
279
  def unitize(other_unit = unit, relative: false)
280
280
  # prefer converting to the thread-specified unit if there is one
281
281
  other_unit = DSL.unit(dimension) || other_unit
282
- logger.trace("Converting #{self} to #{other_unit}")
282
+ logger.trace { "Converting #{self} to #{other_unit}" }
283
283
 
284
284
  case unit
285
285
  when Units::ONE
@@ -41,7 +41,7 @@ module OpenHAB
41
41
  # `nil` is returned if the two values are incomparable.
42
42
  #
43
43
  def <=>(other)
44
- logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})")
44
+ logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" }
45
45
  if other.respond_to?(:to_str)
46
46
  to_str <=> other.to_str
47
47
  elsif other.respond_to?(:coerce)
@@ -61,7 +61,7 @@ module OpenHAB
61
61
  # @return [[StringType, StringType], nil]
62
62
  #
63
63
  def coerce(other)
64
- logger.trace("Coercing #{self} as a request from #{other.class}")
64
+ logger.trace { "Coercing #{self} as a request from #{other.class}" }
65
65
  [other.to_str, self] if other.respond_to?(:to_str)
66
66
  end
67
67
 
@@ -55,7 +55,7 @@ module OpenHAB
55
55
  states = Types::PREDICATE_ALIASES[value.to_s]
56
56
 
57
57
  ([command] | states).each do |method|
58
- logger.trace("Defining #{klass}##{method} for #{value}")
58
+ logger.trace { "Defining #{klass}##{method} for #{value}" }
59
59
  klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
60
60
  def #{method} # def on?
61
61
  as(#{value.class.java_class.simple_name}).equal?(#{value}) # as(OnOffType).equal?(ON)
data/lib/openhab/core.rb CHANGED
@@ -38,7 +38,7 @@ module OpenHAB
38
38
  def wait_till_openhab_ready
39
39
  logger.trace("Checking readiness of openHAB")
40
40
  until automation_manager
41
- logger.trace("Automation manager not loaded, checking again in #{CHECK_DELAY} seconds.")
41
+ logger.trace { "Automation manager not loaded, checking again in #{CHECK_DELAY} seconds." }
42
42
  sleep CHECK_DELAY
43
43
  end
44
44
  logger.trace "Automation manager instantiated, openHAB ready for rule processing."
@@ -20,7 +20,7 @@ module OpenHAB
20
20
  # @return [MonthDay]
21
21
  #
22
22
  def parse(string)
23
- logger.trace("#{self.class}.parse #{string} (#{string.class})")
23
+ logger.trace { "#{self.class}.parse #{string} (#{string.class})" }
24
24
  java_send(:parse,
25
25
  [java.lang.CharSequence, java.time.format.DateTimeFormatter],
26
26
  string.to_s,
@@ -104,7 +104,7 @@ module OpenHAB
104
104
  @listener ||= org.openhab.core.common.registry.RegistryChangeListener.impl do |method, element|
105
105
  next unless method == :removed
106
106
 
107
- logger.trace("Rule #{element.inspect} removed from registry")
107
+ logger.trace { "Rule #{element.inspect} removed from registry" }
108
108
  next unless element.uid == uid
109
109
 
110
110
  cleanup
@@ -225,7 +225,7 @@ module OpenHAB
225
225
 
226
226
  return true if @guard.should_run?(event)
227
227
 
228
- logger.trace("Skipped execution of rule '#{name}' because of guard #{@guard}")
228
+ logger.trace { "Skipped execution of rule '#{name}' because of guard #{@guard}" }
229
229
  false
230
230
  end
231
231
 
@@ -37,7 +37,7 @@ module OpenHAB
37
37
  # @return [true,false] True if guard is satisfied, false otherwise
38
38
  #
39
39
  def should_run?(event)
40
- logger.trace("Checking guards #{self}")
40
+ logger.trace { "Checking guards #{self}" }
41
41
  return false unless check_only_if(event)
42
42
  return false unless check_not_if(event)
43
43
 
@@ -44,7 +44,7 @@ module OpenHAB
44
44
  def append_trigger(type:, config:, attach: nil, conditions: nil, label: nil)
45
45
  config.transform_keys!(&:to_s)
46
46
  RuleTriggers.trigger(type: type, config: config, label: label).tap do |trigger|
47
- logger.trace("Appending trigger (#{trigger.inspect}) attach (#{attach}) conditions(#{conditions})")
47
+ logger.trace { "Appending trigger (#{trigger.inspect}) attach (#{attach}) conditions(#{conditions})" }
48
48
  @triggers << trigger
49
49
  @attachments[trigger.id] = attach if attach
50
50
  @trigger_conditions[trigger.id] = conditions if conditions
@@ -61,7 +61,7 @@ module OpenHAB
61
61
  # @return [org.openhab.core.automation.Trigger] configured by type and supplied config
62
62
  #
63
63
  def self.trigger(type:, config:, label: nil)
64
- logger.trace("Creating trigger of type '#{type}' config: #{config}")
64
+ logger.trace { "Creating trigger of type '#{type}' config: #{config}" }
65
65
  org.openhab.core.automation.util.TriggerBuilder.create
66
66
  .with_id(uuid)
67
67
  .with_type_uid(type)
@@ -22,8 +22,10 @@ module OpenHAB
22
22
  @conditions = Generic.new(to: to, from: from)
23
23
  @duration = duration
24
24
  @timers = {}
25
- logger.trace "Created Duration Condition To(#{to}) From(#{from}) " \
26
- "Conditions(#{@conditions}) Duration(#{@duration})"
25
+ logger.trace do
26
+ "Created Duration Condition To(#{to}) From(#{from}) " \
27
+ "Conditions(#{@conditions}) Duration(#{@duration})"
28
+ end
27
29
  end
28
30
 
29
31
  # Process rule
@@ -34,13 +36,13 @@ module OpenHAB
34
36
  if timer&.active?
35
37
  process_active_timer(timer, inputs, mod, &block)
36
38
  elsif @conditions.process(mod: mod, inputs: inputs)
37
- logger.trace("Trigger Guards Matched for #{self}, delaying rule execution")
39
+ logger.trace { "Trigger Guards Matched for #{self}, delaying rule execution" }
38
40
  # Add timer and attach timer to delay object, and also state being tracked to so
39
41
  # timer can be cancelled if state changes
40
42
  # Also another timer should not be created if changed to same value again but instead rescheduled
41
43
  create_trigger_delay_timer(inputs, mod, &block)
42
44
  else
43
- logger.trace("Trigger Guards did not match for #{self}, ignoring trigger.")
45
+ logger.trace { "Trigger Guards did not match for #{self}, ignoring trigger." }
44
46
  end
45
47
  end
46
48
 
@@ -61,10 +63,10 @@ module OpenHAB
61
63
  #
62
64
  #
63
65
  def create_trigger_delay_timer(inputs, _mod)
64
- logger.trace("Creating timer for trigger delay #{self}")
66
+ logger.trace { "Creating timer for trigger delay #{self}" }
65
67
  item_name = inputs["triggeringItem"]&.name
66
68
  @timers[item_name] = DSL.after(@duration) do
67
- logger.trace("Delay Complete for #{self}, executing rule")
69
+ logger.trace { "Delay Complete for #{self}, executing rule" }
68
70
  @timers.delete(item_name)
69
71
  yield
70
72
  end
@@ -83,9 +85,9 @@ module OpenHAB
83
85
  new_state = Conditions.new_state_from(inputs)
84
86
  if @conditions.from? && new_state != @tracking_from &&
85
87
  @conditions.process(mod: nil, inputs: { "state" => new_state })
86
- logger.trace("Item changed from #{old_state} to #{new_state} for #{self}, keep waiting.")
88
+ logger.trace { "Item changed from #{old_state} to #{new_state} for #{self}, keep waiting." }
87
89
  else
88
- logger.trace("Item changed from #{old_state} to #{new_state} for #{self}, canceling timer.")
90
+ logger.trace { "Item changed from #{old_state} to #{new_state} for #{self}, canceling timer." }
89
91
  timer.cancel
90
92
  # Reprocess trigger delay after canceling to track new state (if guards matched, etc)
91
93
  process(mod: mod, inputs: inputs, &block)
@@ -30,7 +30,7 @@ module OpenHAB
30
30
  # @return [true, false] if the conditions passed (and therefore the block was run)
31
31
  #
32
32
  def process(mod:, inputs:)
33
- logger.trace("Checking #{inputs} against condition trigger #{self}")
33
+ logger.trace { "Checking #{inputs} against condition trigger #{self}" }
34
34
  unless check_value(Conditions.old_state_from(inputs), @from) &&
35
35
  check_value(Conditions.new_state_from(inputs), @to) &&
36
36
  check_value(inputs["command"], @command)
@@ -45,7 +45,7 @@ module OpenHAB
45
45
  synchronized do
46
46
  super(callback)
47
47
  @schedule = @scheduler.schedule(self, @expression)
48
- logger.trace("Scheduled cron job '#{@expression}' for trigger '#{@trigger.id}'.")
48
+ logger.trace { "Scheduled cron job '#{@expression}' for trigger '#{@trigger.id}'." }
49
49
  end
50
50
  end
51
51
 
@@ -76,7 +76,7 @@ module OpenHAB
76
76
  @schedule.cancel(true)
77
77
  @schedule = nil
78
78
  end
79
- logger.trace("cancelled job for trigger '#{@trigger.id}'.")
79
+ logger.trace { "cancelled job for trigger '#{@trigger.id}'." }
80
80
  end
81
81
  end
82
82
 
@@ -140,7 +140,7 @@ module OpenHAB
140
140
  # Invoked by java super class to check if sub directories should be watched
141
141
  # @return [false] false
142
142
  def watchSubDirectories
143
- logger.trace("watchSubDirectories returning #{@subdirs}")
143
+ logger.trace { "watchSubDirectories returning #{@subdirs}" }
144
144
  @subdirs
145
145
  end
146
146
 
@@ -45,7 +45,7 @@ module OpenHAB
45
45
  # Add a timer that is now active
46
46
  # @!visibility private
47
47
  def add(timer)
48
- logger.trace("Adding #{timer} to timers")
48
+ logger.trace { "Adding #{timer} to timers" }
49
49
  @timers[timer] = 1
50
50
  end
51
51
 
@@ -54,7 +54,7 @@ module OpenHAB
54
54
  #
55
55
  # @!visibility private
56
56
  def delete(timer)
57
- logger.trace("Removing #{timer} from timers")
57
+ logger.trace { "Removing #{timer} from timers" }
58
58
  return unless @timers.remove(timer) && timer.id
59
59
 
60
60
  @timers_by_id.remove(timer.id)
@@ -193,7 +193,7 @@ module OpenHAB
193
193
  logged = false
194
194
  # don't use #each, in case timers are scheduling more timers
195
195
  until @timers.empty?
196
- logger.trace("Canceling #{@timers.length} timers") unless logged
196
+ logger.trace { "Canceling #{@timers.length} timers" } unless logged
197
197
  logged = true
198
198
  timer = @timers.keys.first
199
199
  timer.cancel
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.27.1"
7
+ VERSION = "5.27.2"
8
8
  end
9
9
  end
data/lib/openhab/dsl.rb CHANGED
@@ -1106,10 +1106,10 @@ module OpenHAB
1106
1106
  return super unless args.empty? && !block_given?
1107
1107
 
1108
1108
  if (context = Thread.current[:openhab_context]) && context.key?(method)
1109
- logger.trace("DSL#method_missing found context variable: '#{method}'")
1109
+ logger.trace { "DSL#method_missing found context variable: '#{method}'" }
1110
1110
  return context[method]
1111
1111
  elsif Core.ui_context&.key?(method)
1112
- logger.trace("DSL#method_missing found UI context variable: '#{method}'")
1112
+ logger.trace { "DSL#method_missing found UI context variable: '#{method}'" }
1113
1113
  return Core.ui_context[method]
1114
1114
  end
1115
1115
  super
@@ -35,7 +35,7 @@ module OpenHAB
35
35
  def handle_event_internal(type, payload, topic, source)
36
36
  event_factory = @typed_event_factories[type]
37
37
  unless event_factory
38
- logger.debug("Could not find an Event Factory for the event type '#{type}'.")
38
+ logger.debug { "Could not find an Event Factory for the event type '#{type}'." }
39
39
  return
40
40
  end
41
41
 
@@ -78,6 +78,7 @@ module OpenHAB
78
78
  )
79
79
  end
80
80
  else
81
+ # Changing this to block syntax will cause specs to fail, for some reason.
81
82
  logger.trace("Skip event subscriber (#{event_subscriber.class}) because of its filter.")
82
83
  end
83
84
  end
@@ -20,7 +20,7 @@ module OpenHAB
20
20
  button2 = nil,
21
21
  button3 = nil
22
22
  )
23
- logger.debug("send_notification: #{email}, #{msg}, #{icon}, #{tag}, #{title}, #{id}, #{on_click}, #{attachment}, #{button1}, #{button2}, #{button3}") # rubocop:disable Layout/LineLength
23
+ logger.debug { "send_notification: #{email}, #{msg}, #{icon}, #{tag}, #{title}, #{id}, #{on_click}, #{attachment}, #{button1}, #{button2}, #{button3}" } # rubocop:disable Layout/LineLength
24
24
  end
25
25
 
26
26
  def send_broadcast_notification(
@@ -35,23 +35,23 @@ module OpenHAB
35
35
  button2 = nil,
36
36
  button3 = nil
37
37
  )
38
- logger.debug("send_broadcast_notification: #{msg}, #{icon}, #{tag}, #{title}, #{id}, #{on_click}, #{attachment}, #{button1}, #{button2}, #{button3}") # rubocop:disable Layout/LineLength
38
+ logger.debug { "send_broadcast_notification: #{msg}, #{icon}, #{tag}, #{title}, #{id}, #{on_click}, #{attachment}, #{button1}, #{button2}, #{button3}" } # rubocop:disable Layout/LineLength
39
39
  end
40
40
 
41
41
  def hide_notification_by_reference_id(email, id)
42
- logger.debug("hide_notification_by_reference_id: #{email}, #{id}")
42
+ logger.debug { "hide_notification_by_reference_id: #{email}, #{id}" }
43
43
  end
44
44
 
45
45
  def hide_notification_by_tag(email, tag)
46
- logger.debug("hide_notification_by_tag: #{email}, #{tag}")
46
+ logger.debug { "hide_notification_by_tag: #{email}, #{tag}" }
47
47
  end
48
48
 
49
49
  def hide_broadcast_notification_by_reference_id(id)
50
- logger.debug("hide_broadcast_notification_by_reference_id: #{id}")
50
+ logger.debug { "hide_broadcast_notification_by_reference_id: #{id}" }
51
51
  end
52
52
 
53
53
  def hide_broadcast_notification_by_tag(tag)
54
- logger.debug("hide_broadcast_notification_by_tag: #{tag}")
54
+ logger.debug { "hide_broadcast_notification_by_tag: #{tag}" }
55
55
  end
56
56
  end
57
57
  end
@@ -59,7 +59,7 @@ module OpenHAB
59
59
  class Voice
60
60
  class << self
61
61
  def say(text, voice: nil, sink: nil, volume: nil)
62
- logger.debug("say: #{text}")
62
+ logger.debug { "say: #{text}" }
63
63
  end
64
64
  end
65
65
  end
@@ -67,11 +67,11 @@ module OpenHAB
67
67
  class Audio
68
68
  class << self
69
69
  def play_sound(filename, sink: nil, volume: nil)
70
- logger.debug("play_sound: #{filename}")
70
+ logger.debug { "play_sound: #{filename}" }
71
71
  end
72
72
 
73
73
  def play_stream(url, sink: nil)
74
- logger.debug("play_stream: #{url}")
74
+ logger.debug { "play_stream: #{url}" }
75
75
  end
76
76
  end
77
77
  end
@@ -9,7 +9,7 @@ module OpenHAB
9
9
  class ::OpenHAB::DSL::Rules::AutomationRule # rubocop:disable Style/ClassAndModuleChildren
10
10
  def execute(mod = nil, inputs = nil)
11
11
  if SuspendRules.suspended?
12
- logger.trace("Skipping execution of #{uid} because rules are suspended.")
12
+ logger.trace { "Skipping execution of #{uid} because rules are suspended." }
13
13
  return
14
14
  end
15
15
  execute!(mod, inputs)
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.27.1
4
+ version: 5.27.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-09-09 00:00:00.000000000 Z
13
+ date: 2024-09-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler