openhab-scripting 5.40.1 → 5.42.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: 7d127126eee03f2bf40f89d87519dc43848d7a37fc270cf74f960571b0591a6a
4
- data.tar.gz: 9798ed530ab09d88cb3698dff764c264cda7e2e0b85b0a57685006f33513203b
3
+ metadata.gz: e14c40c5db6a5210c78c66a315ab449cf71e2960f6de3675f01146b7dd441610
4
+ data.tar.gz: 7862488bf7df6e277c9833e11b15d0e5d54fe6eff3a62fa159dfe26641ab8aad
5
5
  SHA512:
6
- metadata.gz: b9d52444551b2aa6c8a0e0cab506d2aef028e2fe59c983eaf71cac46ba01e8807f1541bc3d790501d555efb2c93f12ec9d3087c43bb72172f43220a37dcd5620
7
- data.tar.gz: 9c4ec38935c532286b9e19a0325870dbccfbe35b6e52dc0d92a47ff30ce6729ce96afa9fdbe14ccf4b2cf6127c727d2e415fd0c3be9af95cb9c64f5a9055f116
6
+ metadata.gz: e72be1db208c31047b81bbba773e6e1f930c7eb47cf61740e151c2d4918e96e192a36fbc3ac94e3ecbece62811f01792574f4bc78d386e14015e66bf4ebf73af
7
+ data.tar.gz: 21a972d3941e63c8ca7729f660c7f60cba586f6d210bed9294c6d81cbfb33df6b9897aa7d4258cdf9f199188a8f90301ac3d353278fb96f4a3e86e0ec198d8d7
@@ -91,20 +91,30 @@ module OpenHAB
91
91
  label || name
92
92
  end
93
93
 
94
- # @!attribute [r] formatted_state
94
+ # @!attribute [r] display_state
95
95
  #
96
96
  # Format the item's state according to its state description
97
97
  #
98
- # This may include running a transformation.
98
+ # This may include running a transformation, if one is defined in the
99
+ # state description's pattern, otherwise it will format according to the
100
+ # pattern. If no state description is defined, the state will simply
101
+ # be returned as a string.
102
+ #
103
+ # @note While this method is also aliased to `#transformed_state` to
104
+ # match the field available in the openHAB REST API, unlike the API it
105
+ # will always return a value even if the state description has no
106
+ # transformation.
99
107
  #
100
108
  # @return [String] The formatted state
101
109
  #
102
110
  # @example
103
- # logger.info(Exterior_WindDirection.formatted_state) # => "NE (36°)"
111
+ # logger.info(Exterior_WindDirection.display_state) # => "NE (36°)"
104
112
  #
105
- def formatted_state
113
+ def display_state
106
114
  Item.item_states_event_builder.get_display_state(self)
107
115
  end
116
+ alias_method :transformed_state, :display_state
117
+ alias_method :formatted_state, :display_state
108
118
 
109
119
  #
110
120
  # Send a command to this item
@@ -40,7 +40,7 @@ module OpenHAB
40
40
  end
41
41
  nil
42
42
  end
43
- alias_method :removeItemMetadata, :remove_item_metadata
43
+ alias_method :removeItemMetadata, :remove_item_metadata # rubocop:disable Naming/MethodName
44
44
  end
45
45
  end
46
46
  end
@@ -37,8 +37,8 @@ module OpenHAB
37
37
  end
38
38
 
39
39
  # @!visibility private
40
- def onCommandFromItem(command)
41
- return unless process_event(:command_from_item, command:) == true
40
+ def onCommandFromItem(command, source = nil)
41
+ return unless process_event(:command_from_item, command:, source:) == true
42
42
 
43
43
  logger.trace("Forwarding original command")
44
44
  @callback.handle_command(command)
@@ -92,6 +92,7 @@ module OpenHAB
92
92
  params[:command] ||= nil
93
93
  params[:trigger] ||= nil
94
94
  params[:time_series] ||= nil
95
+ params[:source] ||= nil
95
96
 
96
97
  kwargs = {}
97
98
  @block.parameters.each do |(param_type, name)|
@@ -40,6 +40,7 @@ module OpenHAB
40
40
  include org.openhab.core.common.registry.ManagedProvider
41
41
  include Enumerable
42
42
  include Singleton
43
+
43
44
  public_class_method :new
44
45
 
45
46
  # Known supported provider types
@@ -183,7 +184,7 @@ module OpenHAB
183
184
  def all
184
185
  @elements.values
185
186
  end
186
- alias_method :getAll, :all
187
+ alias_method :getAll, :all # rubocop:disable Naming/MethodName
187
188
 
188
189
  #
189
190
  # Remove an element from this provider
@@ -25,7 +25,7 @@ module OpenHAB
25
25
  include org.openhab.core.model.sitemap.SitemapProvider
26
26
 
27
27
  # @!visibility private
28
- alias_method :getSitemap, :get
28
+ alias_method :getSitemap, :get # rubocop:disable Naming/MethodName
29
29
 
30
30
  # rubocop:disable Naming/MethodName
31
31
 
@@ -50,7 +50,7 @@ module OpenHAB
50
50
  end
51
51
  count
52
52
  end
53
- alias_method :removeLinksForItem, :remove_links_for_item
53
+ alias_method :removeLinksForItem, :remove_links_for_item # rubocop:disable Naming/MethodName
54
54
 
55
55
  #
56
56
  # Removes all links to a given thing.
@@ -69,7 +69,7 @@ module OpenHAB
69
69
  end
70
70
  count
71
71
  end
72
- alias_method :removeLinksForThing, :remove_links_for_thing
72
+ alias_method :removeLinksForThing, :remove_links_for_thing # rubocop:disable Naming/MethodName
73
73
  end
74
74
  end
75
75
  end
@@ -13,6 +13,7 @@ module OpenHAB
13
13
  # @!visibility private
14
14
  class Proxy < Delegator
15
15
  extend Forwardable
16
+
16
17
  def_delegators :__getobj__, :class, :is_a?, :kind_of?
17
18
 
18
19
  # @!visibility private
data/lib/openhab/core.rb CHANGED
@@ -15,6 +15,8 @@ module OpenHAB
15
15
  V4_3 = Gem::Version.new("4.3.0").freeze
16
16
  # @!visibility private
17
17
  V5_0 = Gem::Version.new("5.0.0").freeze
18
+ # @!visibility private
19
+ V5_1 = Gem::Version.new("5.1.0").freeze
18
20
 
19
21
  # @return [Gem::Version] Returns the current openHAB version as a Gem::Version object
20
22
  # Note, this strips off snapshots, milestones and RC versions and returns the release version.
@@ -16,6 +16,7 @@ module OpenHAB
16
16
  #
17
17
  class Duration
18
18
  include Between
19
+
19
20
  # @!parse include TemporalAmount
20
21
 
21
22
  #
@@ -36,6 +36,7 @@ module OpenHAB
36
36
  #
37
37
  class LocalTime
38
38
  include Between
39
+
39
40
  # @!parse include Time
40
41
 
41
42
  class << self
@@ -10,6 +10,7 @@ module OpenHAB
10
10
  # Extensions to {java.time.Month}
11
11
  class Month
12
12
  include Between
13
+
13
14
  # @!parse include Time
14
15
 
15
16
  # @return [Month]
@@ -169,6 +169,7 @@ module OpenHAB
169
169
  include QuantityTypeConversion
170
170
  # non-Integer/Float (i.e. BigDecimal) can still be converted to Duration, via converting to float first
171
171
  extend Forwardable
172
+
172
173
  def_delegators :to_f,
173
174
  :milliseconds,
174
175
  :millisecond,
@@ -120,10 +120,9 @@ module OpenHAB
120
120
  # @return [Queue] <description>
121
121
  #
122
122
  def create_queue(event)
123
- case check_guards(event:)
124
- when true
123
+ if check_guards?(event:)
125
124
  @run_queue.dup.grep_v(BuilderDSL::Otherwise)
126
- when false
125
+ else
127
126
  @run_queue.dup.grep(BuilderDSL::Otherwise)
128
127
  end
129
128
  end
@@ -211,7 +210,7 @@ module OpenHAB
211
210
  # @return [true,false] True if guards says rule should execute, false otherwise
212
211
  #
213
212
  # Loggging inflates method length
214
- def check_guards(event:)
213
+ def check_guards?(event:)
215
214
  return true if @guard.nil?
216
215
 
217
216
  unless @between.nil?
@@ -162,7 +162,7 @@ module OpenHAB
162
162
  def format_offset(offset)
163
163
  return "" unless offset&.nonzero?
164
164
 
165
- " #{offset.positive? ? "+" : ""}#{offset.seconds.to_s.downcase[2..]}" # Remove "PT" from the ISO8601 string
165
+ " #{"+" if offset.positive?}#{offset.seconds.to_s.downcase[2..]}" # Remove "PT" from the ISO8601 string
166
166
  end
167
167
  end
168
168
  end
@@ -29,11 +29,11 @@ module OpenHAB
29
29
  # @param [Hash] inputs inputs from trigger
30
30
  # @return [true, false] if the conditions passed (and therefore the block was run)
31
31
  #
32
- def process(mod:, inputs:)
32
+ def process(mod:, inputs:) # rubocop:disable Naming/PredicateMethod
33
33
  logger.trace { "Checking #{inputs} against condition trigger #{self}" }
34
- unless check_value(Conditions.old_state_from(inputs), @from) &&
35
- check_value(Conditions.new_state_from(inputs), @to) &&
36
- check_value(inputs["command"], @command)
34
+ unless check_value?(Conditions.old_state_from(inputs), @from) &&
35
+ check_value?(Conditions.new_state_from(inputs), @to) &&
36
+ check_value?(inputs["command"], @command)
37
37
  return false
38
38
  end
39
39
 
@@ -50,7 +50,7 @@ module OpenHAB
50
50
 
51
51
  private
52
52
 
53
- def check_value(value, expected_value)
53
+ def check_value?(value, expected_value)
54
54
  return true if value.nil?
55
55
 
56
56
  return true if expected_value.nil?
@@ -26,6 +26,7 @@ module OpenHAB
26
26
  class Watcher
27
27
  # Use full java class name here to satisfy YARD linter
28
28
  include org.openhab.core.service.WatchService::WatchEventListener
29
+
29
30
  java_import org.openhab.core.service.WatchService
30
31
 
31
32
  # Hash of event symbols as strings to map to WatchService events
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.40.1"
7
+ VERSION = "5.42.0"
8
8
  end
9
9
  end
data/lib/openhab/dsl.rb CHANGED
@@ -58,6 +58,7 @@ module OpenHAB
58
58
  # include this before Core::Actions so that Core::Action's method_missing
59
59
  # takes priority
60
60
  include Core::EntityLookup
61
+
61
62
  #
62
63
  # @!parse
63
64
  # include Core::Actions
@@ -157,6 +158,8 @@ module OpenHAB
157
158
  # @yieldparam [Core::Things::ChannelUID] channel_uid The linked channel.
158
159
  # @yieldparam [Hash] configuration The profile configuration.
159
160
  # @yieldparam [org.openhab.core.thing.profiles.ProfileContext] context The profile context.
161
+ # @yieldparam [String, nil] source The source of the event.
162
+ # @since openHAB 5.1
160
163
  # @yieldreturn [Boolean] Return true from the block in order to have default processing.
161
164
  # @return [void]
162
165
  #
data/lib/openhab/log.rb CHANGED
@@ -384,6 +384,7 @@ module OpenHAB
384
384
  end
385
385
 
386
386
  extend Forwardable
387
+
387
388
  def_delegators :current_logger, *(Logger.public_instance_methods.select do |m|
388
389
  Logger.instance_method(m).owner == Logger
389
390
  end - BasicObject.public_instance_methods)
@@ -15,7 +15,7 @@ module OpenHAB
15
15
  @java_klass = java_klass
16
16
  end
17
17
 
18
- def getStorage(name, _class_loader) # rubocop:disable Naming/MethodName
18
+ def getStorage(name, _class_loader)
19
19
  super(name.sub(@ruby_klass.name, @java_klass.name), @java_klass.class_loader)
20
20
  end
21
21
  end
@@ -97,7 +97,7 @@ module OpenHAB
97
97
  open
98
98
  end
99
99
 
100
- def addingService(reference) # rubocop:disable Naming/MethodName
100
+ def addingService(reference)
101
101
  topics = Array(reference.get_property(org.osgi.service.event.EventConstants::EVENT_TOPIC))
102
102
  topics = nil if topics.empty? || topics.include?("*")
103
103
 
@@ -119,11 +119,11 @@ module OpenHAB
119
119
  service
120
120
  end
121
121
 
122
- def postEvent(event) # rubocop:disable Naming/MethodName
122
+ def postEvent(event)
123
123
  sendEvent(event)
124
124
  end
125
125
 
126
- def sendEvent(event) # rubocop:disable Naming/MethodName
126
+ def sendEvent(event)
127
127
  # prevent re-entrancy
128
128
  if (pending_events = Thread.current[:event_admin_pending_events])
129
129
  pending_events << event
@@ -5,6 +5,7 @@ module OpenHAB
5
5
  # @!visibility private
6
6
  module MarkdownHelper
7
7
  include ::YARD::Templates::Helpers::HtmlHelper
8
+
8
9
  # @group Linking Objects and URLs
9
10
 
10
11
  def diskfile
@@ -44,7 +45,7 @@ module OpenHAB
44
45
  end) + (match ? $`.count("\n") : 0)
45
46
  if match
46
47
  log.warn "In file `#{file}':#{line}: Cannot resolve link to #{name} from text#{match ? ":" : "."}\n" \
47
- "\t#{match[1] ? "..." : ""}#{match[2].delete("\n")}#{match[3] ? "..." : ""}"
48
+ "\t#{"..." if match[1]}#{match[2].delete("\n")}#{"..." if match[3]}"
48
49
  # Don't strip the link. This is so literals like {RUBY_ENGINE_VERSION} remain as they are,
49
50
  # not stripped to "RUBY_ENGINE_VERSION"
50
51
  next str
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.40.1
4
+ version: 5.42.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell