openhab-scripting 4.32.6 → 4.32.7

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openhab/core/entity_lookup.rb +0 -4
  3. data/lib/openhab/core/openhab_setup.rb +1 -2
  4. data/lib/openhab/core/thread_local.rb +12 -2
  5. data/lib/openhab/dsl/actions.rb +2 -0
  6. data/lib/openhab/dsl/between.rb +2 -0
  7. data/lib/openhab/dsl/dsl.rb +2 -2
  8. data/lib/openhab/dsl/group.rb +15 -11
  9. data/lib/openhab/dsl/items/ensure.rb +71 -71
  10. data/lib/openhab/dsl/items/generic_item.rb +1 -1
  11. data/lib/openhab/dsl/items/item_registry.rb +11 -6
  12. data/lib/openhab/dsl/items/items.rb +2 -2
  13. data/lib/openhab/dsl/items/metadata.rb +1 -2
  14. data/lib/openhab/dsl/items/timed_command.rb +7 -6
  15. data/lib/openhab/dsl/monkey_patch/ruby/number.rb +0 -2
  16. data/lib/openhab/dsl/openhab.rb +2 -0
  17. data/lib/openhab/dsl/persistence.rb +2 -0
  18. data/lib/openhab/dsl/rules/automation_rule.rb +4 -5
  19. data/lib/openhab/dsl/rules/rule.rb +104 -95
  20. data/lib/openhab/dsl/rules/rule_config.rb +1 -2
  21. data/lib/openhab/dsl/rules/rule_triggers.rb +1 -3
  22. data/lib/openhab/dsl/rules/terse.rb +1 -1
  23. data/lib/openhab/dsl/rules/triggers/changed.rb +6 -5
  24. data/lib/openhab/dsl/rules/triggers/channel.rb +2 -0
  25. data/lib/openhab/dsl/rules/triggers/command.rb +6 -5
  26. data/lib/openhab/dsl/rules/triggers/conditions/duration.rb +2 -2
  27. data/lib/openhab/dsl/rules/triggers/conditions/proc.rb +2 -2
  28. data/lib/openhab/dsl/rules/triggers/cron/cron.rb +4 -2
  29. data/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb +2 -2
  30. data/lib/openhab/dsl/rules/triggers/generic.rb +3 -2
  31. data/lib/openhab/dsl/rules/triggers/trigger.rb +2 -2
  32. data/lib/openhab/dsl/rules/triggers/updated.rb +9 -8
  33. data/lib/openhab/dsl/rules/triggers/watch/watch.rb +8 -3
  34. data/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb +3 -3
  35. data/lib/openhab/dsl/states.rb +34 -20
  36. data/lib/openhab/dsl/things.rb +2 -0
  37. data/lib/openhab/dsl/time/month_day.rb +2 -2
  38. data/lib/openhab/dsl/timers/manager.rb +4 -3
  39. data/lib/openhab/dsl/timers/reentrant_timer.rb +22 -27
  40. data/lib/openhab/dsl/timers/timer.rb +2 -3
  41. data/lib/openhab/dsl/timers.rb +4 -2
  42. data/lib/openhab/dsl/types/decimal_type.rb +3 -2
  43. data/lib/openhab/dsl/types/point_type.rb +4 -3
  44. data/lib/openhab/dsl/types/quantity_type.rb +0 -4
  45. data/lib/openhab/dsl/types/types.rb +24 -24
  46. data/lib/openhab/dsl/units.rb +2 -0
  47. data/lib/openhab/log/logger.rb +10 -24
  48. data/lib/openhab/version.rb +1 -1
  49. data/lib/openhab.rb +2 -8
  50. metadata +2 -2
@@ -16,115 +16,124 @@ module OpenHAB
16
16
  # Creates and manages OpenHAB Rules
17
17
  #
18
18
  module Rules
19
- include OpenHAB::Core::ThreadLocal
20
- include OpenHAB::Log
19
+ #
20
+ # The main rule DSL method
21
+ #
22
+ module Rule
23
+ include OpenHAB::Log
21
24
 
22
- @script_rules = []
25
+ @script_rules = []
23
26
 
24
- @automation_manager = OpenHAB::Core.automation_manager
25
- @registry = OpenHAB::Core.rule_registry
26
- class << self
27
- attr_reader :script_rules, :automation_manager, :registry
28
- end
27
+ @automation_manager = OpenHAB::Core.automation_manager
28
+ @registry = OpenHAB::Core.rule_registry
29
+ class << self
30
+ attr_reader :script_rules, :automation_manager, :registry
31
+ end
29
32
 
30
- #
31
- # Create a new rule
32
- #
33
- # @param [String] rule_name <description>
34
- # @yield [] Block executed in context of a RuleConfig
35
- #
36
- #
37
- def rule(rule_name, &block)
38
- thread_local(RULE_NAME: rule_name) do
39
- @rule_name = rule_name
40
- config = RuleConfig.new(rule_name, block.binding)
41
- config.instance_exec(config, &block)
42
- config.guard = Guard::Guard.new(run_context: config.caller, only_if: config.only_if, not_if: config.not_if)
43
- logger.trace { config.inspect }
44
- process_rule_config(config)
33
+ module_function
34
+
35
+ #
36
+ # Create a new rule
37
+ #
38
+ # @param [String] rule_name <description>
39
+ # @yield [] Block executed in context of a RuleConfig
40
+ #
41
+ #
42
+ # rubocop:disable Metrics/MethodLength
43
+ def rule(rule_name, &block)
44
+ OpenHAB::Core::ThreadLocal.thread_local(RULE_NAME: rule_name) do
45
+ @rule_name = rule_name
46
+ config = RuleConfig.new(rule_name, block.binding)
47
+ config.instance_exec(config, &block)
48
+ config.guard = Guard::Guard.new(run_context: config.caller, only_if: config.only_if,
49
+ not_if: config.not_if)
50
+ logger.trace { config.inspect }
51
+ process_rule_config(config)
52
+ end
53
+ rescue StandardError => e
54
+ logger.log_exception(e, @rule_name)
45
55
  end
46
- rescue StandardError => e
47
- logger.log_exception(e, @rule_name)
48
- end
56
+ # rubocop:enable Metrics/MethodLength
49
57
 
50
- #
51
- # Cleanup rules in this script file
52
- #
53
- def self.cleanup_rules
54
- @script_rules.each(&:cleanup)
55
- end
56
- Core::ScriptHandling.script_unloaded { cleanup_rules }
58
+ #
59
+ # Cleanup rules in this script file
60
+ #
61
+ def self.cleanup_rules
62
+ @script_rules.each(&:cleanup)
63
+ end
64
+ Core::ScriptHandling.script_unloaded { cleanup_rules }
57
65
 
58
- private
66
+ private
59
67
 
60
- #
61
- # Process a rule based on the supplied configuration
62
- #
63
- # @param [RuleConfig] config for rule
64
- #
65
- #
66
- def process_rule_config(config)
67
- return unless create_rule?(config)
68
+ #
69
+ # Process a rule based on the supplied configuration
70
+ #
71
+ # @param [RuleConfig] config for rule
72
+ #
73
+ #
74
+ def process_rule_config(config)
75
+ return unless create_rule?(config)
68
76
 
69
- rule = AutomationRule.new(config: config)
70
- Rules.script_rules << rule
71
- added_rule = add_rule(rule)
77
+ rule = AutomationRule.new(config: config)
78
+ Rule.script_rules << rule
79
+ added_rule = add_rule(rule)
72
80
 
73
- rule.execute(nil, { 'event' => Struct.new(:attachment).new(config.start_attachment) }) if config.on_start?
74
- added_rule
75
- end
81
+ rule.execute(nil, { 'event' => Struct.new(:attachment).new(config.start_attachment) }) if config.on_start?
82
+ added_rule
83
+ end
76
84
 
77
- #
78
- # Should a rule be created based on rule configuration
79
- #
80
- # @param [RuleConfig] config to check
81
- #
82
- # @return [Boolean] true if it should be created, false otherwise
83
- #
84
- def create_rule?(config)
85
- if !triggers?(config)
86
- logger.warn "Rule '#{config.name}' has no triggers, not creating rule"
87
- elsif !execution_blocks?(config)
88
- logger.warn "Rule '#{config.name}' has no execution blocks, not creating rule"
89
- elsif !config.enabled
90
- logger.trace "Rule '#{config.name}' marked as disabled, not creating rule."
91
- else
92
- return true
85
+ #
86
+ # Should a rule be created based on rule configuration
87
+ #
88
+ # @param [RuleConfig] config to check
89
+ #
90
+ # @return [Boolean] true if it should be created, false otherwise
91
+ #
92
+ def create_rule?(config)
93
+ if !triggers?(config)
94
+ logger.warn "Rule '#{config.name}' has no triggers, not creating rule"
95
+ elsif !execution_blocks?(config)
96
+ logger.warn "Rule '#{config.name}' has no execution blocks, not creating rule"
97
+ elsif !config.enabled
98
+ logger.trace "Rule '#{config.name}' marked as disabled, not creating rule."
99
+ else
100
+ return true
101
+ end
102
+ false
93
103
  end
94
- false
95
- end
96
104
 
97
- #
98
- # Check if the rule has any triggers
99
- #
100
- # @param [RuleConfig] config to check for triggers
101
- #
102
- # @return [Boolean] True if rule has triggers, false otherwise
103
- #
104
- def triggers?(config)
105
- config.on_start? || config.triggers.length.positive?
106
- end
105
+ #
106
+ # Check if the rule has any triggers
107
+ #
108
+ # @param [RuleConfig] config to check for triggers
109
+ #
110
+ # @return [Boolean] True if rule has triggers, false otherwise
111
+ #
112
+ def triggers?(config)
113
+ config.on_start? || config.triggers.length.positive?
114
+ end
107
115
 
108
- #
109
- # Check if the rule has any execution blocks
110
- #
111
- # @param [RuleConfig] config to check for triggers
112
- #
113
- # @return [Boolean] True if rule has execution blocks, false otherwise
114
- #
115
- def execution_blocks?(config)
116
- (config.run || []).length.positive?
117
- end
116
+ #
117
+ # Check if the rule has any execution blocks
118
+ #
119
+ # @param [RuleConfig] config to check for triggers
120
+ #
121
+ # @return [Boolean] True if rule has execution blocks, false otherwise
122
+ #
123
+ def execution_blocks?(config)
124
+ (config.run || []).length.positive?
125
+ end
118
126
 
119
- #
120
- # Add a rule to the automation managed
121
- #
122
- # @param [Java::OrgOpenhabCoreAutomationModuleScriptRulesupportSharedSimple::SimpleRule] rule to add
123
- #
124
- #
125
- def add_rule(rule)
126
- logger.trace("Adding rule: #{rule.inspect}")
127
- Rules.automation_manager.addRule(rule)
127
+ #
128
+ # Add a rule to the automation managed
129
+ #
130
+ # @param [Java::OrgOpenhabCoreAutomationModuleScriptRulesupportSharedSimple::SimpleRule] rule to add
131
+ #
132
+ #
133
+ def add_rule(rule)
134
+ logger.trace("Adding rule: #{rule.inspect}")
135
+ Rule.automation_manager.addRule(rule)
136
+ end
128
137
  end
129
138
  end
130
139
  end
@@ -26,7 +26,6 @@ module OpenHAB
26
26
  prepend OpenHAB::DSL::Rules::Triggers
27
27
  include OpenHAB::DSL::Rules::Guard
28
28
  include OpenHAB::DSL::Rules::Property
29
- extend OpenHAB::DSL
30
29
  extend Forwardable
31
30
 
32
31
  # Provide backwards compatibility for these fields
@@ -86,7 +85,7 @@ module OpenHAB
86
85
  # Start this rule on system startup
87
86
  #
88
87
  # @param [Boolean] run_on_start Run this rule on start, defaults to True
89
- #
88
+ # @param [Object] attach object to be attached to the trigger
90
89
  #
91
90
  # rubocop: disable Style/OptionalBooleanParameter
92
91
  # Disabled cop due to use in a DSL
@@ -33,9 +33,6 @@ module OpenHAB
33
33
  #
34
34
  # Create a new RuleTrigger
35
35
  #
36
- # @param [Object] caller_binding The object initializing this configuration.
37
- # Used to execute within the object's context
38
- #
39
36
  def initialize
40
37
  @triggers = []
41
38
  @trigger_conditions = Hash.new(OpenHAB::DSL::Rules::Triggers::Conditions::Proc::ANY)
@@ -47,6 +44,7 @@ module OpenHAB
47
44
  #
48
45
  # @param [String] type of trigger to create
49
46
  # @param [Map] config map describing trigger configuration
47
+ # @param [Object] attach object to be attached to the trigger
50
48
  #
51
49
  # @return [Trigger] OpenHAB trigger
52
50
  #
@@ -4,7 +4,7 @@ module OpenHAB
4
4
  module DSL
5
5
  module Rules
6
6
  # Module containing terse rule stubs
7
- module Terse
7
+ module TerseRule
8
8
  %i[changed channel cron every updated received_command].each do |trigger|
9
9
  class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
10
10
  def #{trigger}(*args, name: nil, **kwargs, &block) # def changed(*args, name: nil, **kwargs, &block)
@@ -22,6 +22,7 @@ module OpenHAB
22
22
  # @param [to] to state for object to change for
23
23
  # @param [from] from <description>
24
24
  # @param [OpenHAB::Core::Duration] for Duration to delay trigger until to state is met
25
+ # @param [Object] attach object to be attached to the trigger
25
26
  #
26
27
  # @return [Trigger] OpenHAB trigger
27
28
  #
@@ -69,7 +70,7 @@ module OpenHAB
69
70
  # @param [Item State] from state to restrict trigger to
70
71
  # @param [Item State] to state to restrict trigger to
71
72
  # @param [OpenHAB::Core::Duration, nil] duration ruration to delay trigger until to state is met
72
- # @param attach attachment
73
+ # @param [Object] attach object to be attached to the trigger
73
74
  #
74
75
  # @return [Trigger] OpenHAB triggers
75
76
  #
@@ -103,7 +104,7 @@ module OpenHAB
103
104
  # @param [OpenHAB::Core::Duration] duration to delay trigger for until condition is met
104
105
  # @param [Item State] to OpenHAB Item State item or group needs to change to
105
106
  # @param [Item State] from OpenHAB Item State item or group needs to be coming from
106
- # @param [Object] attach to trigger
107
+ # @param [Object] attach object to be attached to the trigger
107
108
  #
108
109
  # @return [Trigger] OpenHAB trigger
109
110
  #
@@ -120,7 +121,7 @@ module OpenHAB
120
121
  # @param [Object] item to create changed trigger on
121
122
  # @param [Object] from state to restrict trigger to
122
123
  # @param [Object] to state restrict trigger to
123
- # @param [Object] attach to trigger
124
+ # @param [Object] attach object to be attached to the trigger
124
125
  # @return [Trigger] OpenHAB trigger
125
126
  #
126
127
  def range_trigger(item:, from:, to:, attach:)
@@ -133,7 +134,7 @@ module OpenHAB
133
134
  # @param [Object] item to create changed trigger on
134
135
  # @param [Object] from state to restrict trigger to
135
136
  # @param [Object] to state restrict trigger to
136
- # @param [Object] attach to trigger
137
+ # @param [Object] attach object to be attached to the trigger
137
138
  # @return [Trigger] OpenHAB trigger
138
139
  #
139
140
  def proc_trigger(item:, from:, to:, attach:)
@@ -152,7 +153,7 @@ module OpenHAB
152
153
  # @param [Object] item to create changed trigger on
153
154
  # @param [Object] from state to restrict trigger to
154
155
  # @param [Object] to state restrict trigger to
155
- #
156
+ # @param [Object] attach object to be attached to the trigger
156
157
  #
157
158
  def changed_trigger(item:, from:, to:, attach: nil, conditions: nil)
158
159
  type, config = case item
@@ -22,6 +22,7 @@ module OpenHAB
22
22
  # @param [String, Thing, ThingUID, Array<String, Thing, ThingUID>] thing
23
23
  # thing(s) to create trigger for if not specified with the channel
24
24
  # @param [String, Array<String>] triggered specific triggering condition(s) to match for trigger
25
+ # @param [Object] attach object to be attached to the trigger
25
26
  #
26
27
  def channel(*channels, thing: nil, triggered: nil, attach: nil)
27
28
  channel_trigger = Channel.new(rule_triggers: @rule_triggers)
@@ -68,6 +69,7 @@ module OpenHAB
68
69
  #
69
70
  # @param [String] channel to look for triggers
70
71
  # @param [String] trigger specific channel trigger to match
72
+ # @param [Object] attach object to be attached to the trigger
71
73
  #
72
74
  #
73
75
  def trigger(channel:, trigger:, attach:)
@@ -20,6 +20,7 @@ module OpenHAB
20
20
  # @param [Array] items Array of items to create trigger for
21
21
  # @param [Array] command commands to match for trigger
22
22
  # @param [Array] commands commands to match for trigger
23
+ # @param [Object] attach object to be attached to the trigger
23
24
  #
24
25
  #
25
26
  def received_command(*items, command: nil, commands: nil, attach: nil)
@@ -63,7 +64,7 @@ module OpenHAB
63
64
  #
64
65
  # @param [Object] item item to create trigger for
65
66
  # @param [Object] command to check against
66
- # @param [Object] attach attachment
67
+ # @param [Object] attach object to be attached to the trigger
67
68
  #
68
69
  # @return [Trigger] OpenHAB triggers
69
70
  #
@@ -79,7 +80,7 @@ module OpenHAB
79
80
  # Creates a trigger with a range condition on the 'command' field
80
81
  # @param [Object] item to create changed trigger on
81
82
  # @param [Object] command to restrict trigger to
82
- # @param [Object] attach to trigger
83
+ # @param [Object] attach object to be attached to the trigger
83
84
  # @return [Trigger] OpenHAB trigger
84
85
  #
85
86
  def range_trigger(item:, command:, attach:)
@@ -91,7 +92,7 @@ module OpenHAB
91
92
  # Creates a trigger with a proc condition on the 'command' field
92
93
  # @param [Object] item to create changed trigger on
93
94
  # @param [Object] command to restrict trigger to
94
- # @param [Object] attach to trigger
95
+ # @param [Object] attach object to be attached to the trigger
95
96
  # @return [Trigger] OpenHAB trigger
96
97
  #
97
98
  def proc_trigger(item:, command:, attach:)
@@ -102,9 +103,9 @@ module OpenHAB
102
103
  #
103
104
  # Create a received trigger based on item type
104
105
  #
105
- # @param [Array] commands to create trigger for
106
106
  # @param [Object] item to create trigger for
107
- #
107
+ # @param [String] command to create trigger for
108
+ # @param [Object] attach object to be attached to the trigger
108
109
  #
109
110
  def command_trigger(item:, command:, attach: nil, conditions: nil)
110
111
  type, config = if item.is_a? OpenHAB::DSL::Items::GroupItem::GroupMembers
@@ -28,7 +28,7 @@ module OpenHAB
28
28
  # Create a new duration condition
29
29
  # @param [Object] to optional condition on to state
30
30
  # @param [Object] from optional condition on from state
31
- # @param [Duration] Duration to state must stay at specific value before triggering
31
+ # @param [Duration] duration to state must stay at specific value before triggering
32
32
  #
33
33
  def initialize(to:, from:, duration:)
34
34
  to = Conditions::Proc.from_value(to)
@@ -118,7 +118,7 @@ module OpenHAB
118
118
  # Creates a timer for trigger delays
119
119
  #
120
120
  # @param [Hash] inputs rule trigger inputs
121
- # @param [Hash] mod rule trigger mods
121
+ # @param [Hash] _mod rule trigger mods
122
122
  #
123
123
  #
124
124
  def create_trigger_delay_timer(inputs, _mod)
@@ -45,8 +45,8 @@ module OpenHAB
45
45
  end
46
46
 
47
47
  #
48
- # Create a range proc for the supplied range object
49
- # @param [Range] range to build proc for
48
+ # Create an equality proc for the supplied range object
49
+ # @param [State] value to build proc for
50
50
  #
51
51
  def self.equality_proc(value)
52
52
  logger.trace("Creating equality proc for #{value}")
@@ -15,6 +15,7 @@ module OpenHAB
15
15
  #
16
16
  # @param [Object] value Symbol or Duration to execute this rule
17
17
  # @param [Object] at TimeOfDay or String representing TimeOfDay in which to execute rule
18
+ # @param [Object] attach object to be attached to the trigger
18
19
  #
19
20
  #
20
21
  def every(value, at: nil, attach: nil)
@@ -30,6 +31,7 @@ module OpenHAB
30
31
  # Create a OpenHAB Cron trigger
31
32
  #
32
33
  # @param [String] expression OpenHAB style cron expression
34
+ # @param [Object] attach object to be attached to the trigger
33
35
  #
34
36
  def cron(expression, attach: nil)
35
37
  cron = Cron.new(rule_triggers: @rule_triggers)
@@ -171,8 +173,8 @@ module OpenHAB
171
173
  #
172
174
  # Create a cron trigger based on item type
173
175
  #
174
- # @param [Array] commands to create trigger for
175
- # @param [Object] item to create trigger for
176
+ # @param [Config] config Rule configuration
177
+ # @param [Object] attach object to be attached to the trigger
176
178
  #
177
179
  #
178
180
  def trigger(config:, attach:)
@@ -57,7 +57,7 @@ module OpenHAB
57
57
  field_accessor :callback
58
58
 
59
59
  # Creates a new CronTriggerHandler
60
- # @param [Trigger] OpenHAB trigger associated with handler
60
+ # @param [Trigger] trigger OpenHAB trigger associated with handler
61
61
  #
62
62
  def initialize(trigger)
63
63
  @trigger = trigger
@@ -113,7 +113,7 @@ module OpenHAB
113
113
  include org.openhab.core.automation.module.script.rulesupport.shared.factories.ScriptedTriggerHandlerFactory
114
114
 
115
115
  # Invoked by the OpenHAB core to get a trigger handler for the supllied trigger
116
- # @param [Trigger] OpenHAB trigger
116
+ # @param [Trigger] trigger OpenHAB trigger
117
117
  #
118
118
  # @return [WatchTriggerHandler] trigger handler for supplied trigger
119
119
  def get(trigger)
@@ -15,8 +15,9 @@ module OpenHAB
15
15
  #
16
16
  # Create a generic trigger given the trigger type uid and a configuration hash
17
17
  #
18
- # @param [Type] Trigger type UID
19
- # @param [Configuration] A hash containing the trigger configuration entries
18
+ # @param [Type] type Trigger type UID
19
+ # @param [Object] attach object to be attached to the trigger
20
+ # @param [Configuration] configuration A hash containing the trigger configuration entries
20
21
  #
21
22
  # @return [Trigger] Trigger object
22
23
  #
@@ -38,7 +38,7 @@ module OpenHAB
38
38
 
39
39
  #
40
40
  # Creates a new Trigger
41
- # @param [RuleTrigger] rule trigger information
41
+ # @param [RuleTrigger] rule_triggers rule trigger information
42
42
  def initialize(rule_triggers:)
43
43
  @rule_triggers = rule_triggers
44
44
  end
@@ -47,7 +47,7 @@ module OpenHAB
47
47
  # Create a trigger for a thing
48
48
  #
49
49
  # @param [Thing] thing to create trigger for
50
- # @param [Trigger] trigger to map with thing
50
+ # @param [Trigger] type trigger to map with thing
51
51
  # @param [State] to for thing
52
52
  # @param [State] from state of thing
53
53
  #
@@ -17,6 +17,7 @@ module OpenHAB
17
17
  #
18
18
  # @param [Array] items array to trigger on updated
19
19
  # @param [State] to to match for tigger
20
+ # @param [Object] attach object to be attached to the trigger
20
21
  #
21
22
  # @return [Trigger] Trigger for updated entity
22
23
  #
@@ -40,9 +41,8 @@ module OpenHAB
40
41
  # Create the trigger
41
42
  #
42
43
  # @param [Object] item item to create trigger for
43
- # @param [Item State] from state to restrict trigger to
44
44
  # @param [Item State] to state to restrict trigger to
45
- # @param attach attachment
45
+ # @param [Object] attach object to be attached to the trigger
46
46
  #
47
47
  # @return [Trigger] OpenHAB triggers
48
48
  #
@@ -69,7 +69,7 @@ module OpenHAB
69
69
  # Creates a trigger with a range condition on the 'to' field
70
70
  # @param [Object] item to create changed trigger on
71
71
  # @param [Object] to state restrict trigger to
72
- # @param [Object] attach to trigger
72
+ # @param [Object] attach object to be attached to the trigger
73
73
  # @return [Trigger] OpenHAB trigger
74
74
  #
75
75
  def range_trigger(item:, to:, attach:)
@@ -81,7 +81,7 @@ module OpenHAB
81
81
  # Creates a trigger with a proc condition on the 'to' field
82
82
  # @param [Object] item to create changed trigger on
83
83
  # @param [Object] to state restrict trigger to
84
- # @param [Object] attach to trigger
84
+ # @param [Object] attach object to be attached to the trigger
85
85
  # @return [Trigger] OpenHAB trigger
86
86
  #
87
87
  def proc_trigger(item:, to:, attach:)
@@ -93,7 +93,8 @@ module OpenHAB
93
93
  # Create a trigger for updates
94
94
  #
95
95
  # @param [Object] item Type of item [Group,Thing,Item] to create update trigger for
96
- # @param [State] to_state state restriction on trigger
96
+ # @param [State] to state restriction on trigger
97
+ # @param [Object] attach object to be attached to the trigger
97
98
  #
98
99
  # @return [Trigger] OpenHAB triggers
99
100
  #
@@ -110,7 +111,7 @@ module OpenHAB
110
111
  # Create an update trigger for an item
111
112
  #
112
113
  # @param [Item] item to create trigger for
113
- # @param [State] to_state optional state restriction for target
114
+ # @param [State] to optional state restriction for target
114
115
  #
115
116
  # @return [Array<Hash,String>] first element is a String specifying trigger type
116
117
  # second element is a Hash configuring trigger
@@ -125,7 +126,7 @@ module OpenHAB
125
126
  # Create an update trigger for a group
126
127
  #
127
128
  # @param [Item] item to create trigger for
128
- # @param [State] to_state optional state restriction for target
129
+ # @param [State] to optional state restriction for target
129
130
  #
130
131
  # @return [Array<Hash,String>] first element is a String specifying trigger type
131
132
  # second element is a Hash configuring trigger
@@ -140,7 +141,7 @@ module OpenHAB
140
141
  # Create an update trigger for a thing
141
142
  #
142
143
  # @param [Thing] thing to create trigger for
143
- # @param [State] to_state optional state restriction for target
144
+ # @param [State] to optional state restriction for target
144
145
  #
145
146
  # @return [Array<Hash,String>] first element is a String specifying trigger type
146
147
  # second element is a Hash configuring trigger
@@ -18,6 +18,9 @@ module OpenHAB
18
18
  # Create a trigger to watch a path
19
19
  #
20
20
  # @param [String] path to watch
21
+ # @param [String] glob
22
+ # @param [Array, Symbol] for types of changes to watch: +:created+, +:deleted+, +:modified+
23
+ # @param [Object] attach object to be attached to the trigger
21
24
  #
22
25
  # @return [Trigger] Trigger object
23
26
  #
@@ -40,10 +43,12 @@ module OpenHAB
40
43
 
41
44
  #
42
45
  # Automatically creates globs for supplied paths if necessary
46
+ #
43
47
  # @param [Pathname] path to check
44
- # @param [String] specified glob
48
+ # @param [String] glob
45
49
  #
46
50
  # @return [Pathname,String] Pathname to watch and glob to match
51
+ #
47
52
  def self.glob_for_path(path, glob)
48
53
  # Checks if the supplied pathname last element contains a glob char
49
54
  if GLOB_CHARS.any? { |char| path.basename.to_s.include? char }
@@ -60,8 +65,8 @@ module OpenHAB
60
65
  #
61
66
  # Create a watch trigger based on item type
62
67
  #
63
- # @param [Array] commands to create trigger for
64
- # @param [Object] item to create trigger for
68
+ # @param [Config] config Rule configuration
69
+ # @param [Object] attach object to be attached to the trigger
65
70
  #
66
71
  #
67
72
  def trigger(config:, attach:)
@@ -79,7 +79,7 @@ module OpenHAB
79
79
  # Invoked by java super class when an watch event occurs
80
80
  # @param [String] _event ignored
81
81
  # @param [StandardWatchEventKind] kind NIO watch event kind
82
- # @param [java.nio.Path] Path that had an event
82
+ # @param [java.nio.Path] path that had an event
83
83
  def processWatchEvent(_event, kind, path)
84
84
  @block.call(WatchEvent.new(EVENT_TO_SYMBOL[kind], Pathname.new(path.to_s)))
85
85
  end
@@ -92,7 +92,7 @@ module OpenHAB
92
92
  include org.openhab.core.automation.handler.TriggerHandler
93
93
 
94
94
  # Creates a new WatchTriggerHandler
95
- # @param [Trigger] OpenHAB trigger associated with handler
95
+ # @param [Trigger] trigger OpenHAB trigger associated with handler
96
96
  #
97
97
  def initialize(trigger)
98
98
  @trigger = trigger
@@ -139,7 +139,7 @@ module OpenHAB
139
139
  include org.openhab.core.automation.module.script.rulesupport.shared.factories.ScriptedTriggerHandlerFactory
140
140
 
141
141
  # Invoked by the OpenHAB core to get a trigger handler for the supllied trigger
142
- # @param [Trigger] OpenHAB trigger
142
+ # @param [Trigger] trigger OpenHAB trigger
143
143
  #
144
144
  # @return [WatchTriggerHandler] trigger handler for supplied trigger
145
145
  def get(trigger)