openhab-scripting 5.0.0 → 5.0.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: a2826f669c876cc9b59863c2107bc8b1af62327d22c4551ef062f1b7bc97aabb
4
- data.tar.gz: 61bd119ddc94019361d0150ed8bc1e92b5b42de9f610599f1305fbf04055cb14
3
+ metadata.gz: 68c866fadb2ec59386b79d7cf485f943291ca68670d473f5986ca8dc07880ff3
4
+ data.tar.gz: 9e8fb64b69836d4c09151182fe141abd3edf89335fef740da61c6d0dee568966
5
5
  SHA512:
6
- metadata.gz: 0bf813e7b4aba75c75979c05fc317982dfb1ca94b0eae9de656ed342b1861b293ebb8912ed7935ba709b90506a169be6013b92278281ab4dafdb3205e215f927
7
- data.tar.gz: 74a35427271bcae3fd179c3ffd1710f145457e8ae1010481b27310aa28bf710c359f784c6893ed630f2737f1f029c43b7c5f925ceed7cb119239c7cfe77a77e7
6
+ metadata.gz: 1c8d424bc4c0a225e667d29db37feb0b401de28bc2034de483e67d0b437818645fff89db102a911a2612041058c38229cdafd6e4934159a5e9a19734e53ea5e0
7
+ data.tar.gz: ee0579104e4b8e33aa31de24c9a61d4a1d77e53250ca8ad3f2063f0bdd0efe81dcf1b69a75c9da5ab090e8f85a6a9f57979f11d0bad41e574f9987234fa5dbf9
@@ -23,7 +23,14 @@ module OpenHAB
23
23
  #
24
24
  def play_sound(filename, sink: nil, volume: nil)
25
25
  volume = PercentType.new(volume) unless volume.is_a?(PercentType) || volume.nil?
26
- playSound(sink&.to_s, filename.to_s, volume)
26
+ # JRuby calls the wrong overloaded method when volume is given, but sink is nil
27
+ # will call playSound(String, String, float) instead of playSound(String, String, PercentType)
28
+ # and end up with argument type mismatched. So we need to give it a bit of help here.
29
+ if sink
30
+ playSound(sink.to_s, filename.to_s, volume)
31
+ else
32
+ playSound(filename.to_s, volume)
33
+ end
27
34
  end
28
35
 
29
36
  #
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "item_state_event"
4
+
5
+ module OpenHAB
6
+ module Core
7
+ module Events
8
+ begin
9
+ java_import org.openhab.core.items.events.ItemStateUpdatedEvent
10
+
11
+ #
12
+ # {AbstractEvent} sent when an item's state has updated.
13
+ #
14
+ class ItemStateUpdatedEvent < ItemEvent
15
+ include ItemState
16
+ end
17
+ rescue NameError
18
+ # @deprecated OH3.4 OH3 will raise an error ItemStateUpdatedEvent is only in OH4
19
+ end
20
+ end
21
+ end
22
+ end
@@ -70,6 +70,24 @@ module OpenHAB
70
70
 
71
71
  provider.remove(rule_uid)
72
72
  end
73
+
74
+ #
75
+ # Returns all Scenes (rules tagged with "Scene")
76
+ #
77
+ # @return [Array<Rule>] A list of all the scenes
78
+ #
79
+ def scenes
80
+ tagged("Scene")
81
+ end
82
+
83
+ #
84
+ # Returns all Scripts (rules tagged with "Script")
85
+ #
86
+ # @return [Array<Rule>] A list of all the scripts
87
+ #
88
+ def scripts
89
+ tagged("Script")
90
+ end
73
91
  end
74
92
  end
75
93
  end
@@ -11,6 +11,15 @@ module OpenHAB
11
11
  # met, enabling the core dynamic functionality of openHAB.
12
12
  #
13
13
  module Rule
14
+ # @!attribute [r] name
15
+ # @return [String,nil] The rule's human-readable name
16
+
17
+ # @!attribute [r] description
18
+ # @return [String,nil] The rule's description
19
+
20
+ # @!attribute [r] tags
21
+ # @return [Array<Tag>] The rule's list of tags
22
+
14
23
  #
15
24
  # @!method visible?
16
25
  # Check if visibility == `VISIBLE`
@@ -102,12 +111,27 @@ module OpenHAB
102
111
  info.nil? || info.status_detail == RuleStatusDetail::DISABLED
103
112
  end
104
113
 
114
+ #
115
+ # Checks if this rule has at least one of the given tags.
116
+ #
117
+ # (see Items::Item#tagged)
118
+ #
119
+ # @example Find rules tagged with "Halloween"
120
+ # rules.tagged?("Halloweed")
121
+ #
122
+ def tagged?(*tags)
123
+ tags.map! do |tag|
124
+ tag.is_a?(::Module) ? tag.simple_name : tag # ::Module to distinguish against Rule::Module!
125
+ end
126
+ !(self.tags.to_a & tags).empty?
127
+ end
128
+
105
129
  #
106
130
  # @!attribute [r] status
107
- # @return [RuleStatus nil]
131
+ # @return [RuleStatus, nil]
108
132
  #
109
133
  def status
110
- Rules.manager.get_status(uid)
134
+ Rules.manager&.get_status(uid)
111
135
  end
112
136
 
113
137
  #
@@ -115,7 +139,7 @@ module OpenHAB
115
139
  # @return [RuleStatusInfo, nil]
116
140
  #
117
141
  def status_info
118
- Rules.manager.get_status_info(uid)
142
+ Rules.manager&.get_status_info(uid)
119
143
  end
120
144
 
121
145
  # @return [String]
@@ -76,8 +76,10 @@ module OpenHAB
76
76
  # This method gets called in rspec's SuspendRules as well
77
77
  def execute!(mod, inputs)
78
78
  ThreadLocal.thread_local(**@thread_locals) do
79
- logger.trace { "Execute called with mod (#{mod&.to_string}) and inputs (#{inputs.inspect})" }
80
- logger.trace { "Event details #{inputs["event"].inspect}" } if inputs&.key?("event")
79
+ if logger.trace?
80
+ logger.trace("Execute called with mod (#{mod&.to_string}) and inputs (#{inputs.inspect})")
81
+ logger.trace("Event details #{inputs["event"].inspect}") if inputs&.key?("event")
82
+ end
81
83
  trigger_conditions(inputs).process(mod: mod, inputs: inputs) do
82
84
  event = extract_event(inputs)
83
85
  @debouncer.call { process_queue(create_queue(event), mod, event) }
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.0.0"
7
+ VERSION = "5.0.1"
8
8
  end
9
9
  end
data/lib/openhab/dsl.rb CHANGED
@@ -500,7 +500,7 @@ module OpenHAB
500
500
  # @example Prevent door bell from ringing repeatedly
501
501
  # # This can be called from a UI rule.
502
502
  # # For file based rule, use the `only_every` rule guard
503
- # only_every(30.seconds) do { Audio.play_sound("doorbell.mp3") }
503
+ # only_every(30.seconds) { Audio.play_sound("doorbell.mp3") }
504
504
  #
505
505
  # @see Rules::BuilderDSL#debounce_for Rule builder's debounce_for for a detailed description
506
506
  # @see Rules::BuilderDSL#only_every
@@ -45,7 +45,7 @@ module OpenHAB
45
45
  html.css("h1, h2, h3, h4, h5, h6").each do |header|
46
46
  next if header["id"]
47
47
 
48
- id = header.text.strip.downcase.delete(%(.?"')).tr(" ", "-")
48
+ id = header.text.strip.downcase.delete(%(.?"')).gsub(/[ ,]+/, "-")
49
49
  header["id"] = id
50
50
  header.prepend_child(%(<a href="##{id}" class="header-anchor">#</a>))
51
51
  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.0.0
4
+ version: 5.0.1
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: 2023-03-08 00:00:00.000000000 Z
13
+ date: 2023-04-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -379,6 +379,7 @@ files:
379
379
  - lib/openhab/core/events/item_event.rb
380
380
  - lib/openhab/core/events/item_state_changed_event.rb
381
381
  - lib/openhab/core/events/item_state_event.rb
382
+ - lib/openhab/core/events/item_state_updated_event.rb
382
383
  - lib/openhab/core/events/thing_status_info_event.rb
383
384
  - lib/openhab/core/items.rb
384
385
  - lib/openhab/core/items/accepted_data_types.rb