openhab-scripting 4.46.2 → 5.0.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 +4 -4
- data/lib/openhab/core/actions/audio.rb +47 -0
- data/lib/openhab/core/actions/ephemeris.rb +39 -0
- data/lib/openhab/core/actions/exec.rb +51 -0
- data/lib/openhab/core/actions/http.rb +80 -0
- data/lib/openhab/core/actions/ping.rb +30 -0
- data/lib/openhab/core/actions/transformation.rb +32 -0
- data/lib/openhab/core/actions/voice.rb +36 -0
- data/lib/openhab/core/actions.rb +82 -0
- data/lib/openhab/core/dependency_tracking.rb +34 -0
- data/lib/openhab/core/dto/item_channel_link.rb +33 -0
- data/lib/openhab/core/dto/thing.rb +27 -0
- data/lib/openhab/core/dto.rb +11 -0
- data/lib/openhab/core/entity_lookup.rb +152 -70
- data/lib/openhab/core/events/abstract_event.rb +18 -0
- data/lib/openhab/core/events/abstract_item_registry_event.rb +36 -0
- data/lib/openhab/core/events/abstract_thing_registry_event.rb +40 -0
- data/lib/openhab/core/events/item_command_event.rb +78 -0
- data/lib/openhab/core/events/item_event.rb +22 -0
- data/lib/openhab/core/events/item_state_changed_event.rb +75 -0
- data/lib/openhab/core/events/item_state_event.rb +79 -0
- data/lib/openhab/core/events/thing_status_info_event.rb +55 -0
- data/lib/openhab/core/events.rb +10 -0
- data/lib/openhab/core/items/accepted_data_types.rb +29 -0
- data/lib/openhab/core/items/color_item.rb +52 -0
- data/lib/openhab/core/items/contact_item.rb +52 -0
- data/lib/openhab/core/items/date_time_item.rb +59 -0
- data/lib/openhab/core/items/dimmer_item.rb +148 -0
- data/lib/openhab/core/items/generic_item.rb +292 -0
- data/lib/openhab/core/items/group_item.rb +176 -0
- data/lib/openhab/{dsl → core}/items/image_item.rb +35 -29
- data/lib/openhab/core/items/item.rb +273 -0
- data/lib/openhab/core/items/location_item.rb +34 -0
- data/lib/openhab/core/items/metadata/hash.rb +433 -0
- data/lib/openhab/core/items/metadata/namespace_hash.rb +475 -0
- data/lib/openhab/core/items/metadata/provider.rb +48 -0
- data/lib/openhab/core/items/metadata.rb +11 -0
- data/lib/openhab/core/items/number_item.rb +62 -0
- data/lib/openhab/core/items/numeric_item.rb +22 -0
- data/lib/openhab/core/items/persistence.rb +416 -0
- data/lib/openhab/core/items/player_item.rb +66 -0
- data/lib/openhab/core/items/provider.rb +44 -0
- data/lib/openhab/core/items/proxy.rb +136 -0
- data/lib/openhab/core/items/registry.rb +86 -0
- data/lib/openhab/core/items/rollershutter_item.rb +68 -0
- data/lib/openhab/core/items/semantics/enumerable.rb +177 -0
- data/lib/openhab/core/items/semantics.rb +473 -0
- data/lib/openhab/core/items/state_storage.rb +53 -0
- data/lib/openhab/core/items/string_item.rb +28 -0
- data/lib/openhab/core/items/switch_item.rb +78 -0
- data/lib/openhab/core/items.rb +108 -0
- data/lib/openhab/{dsl → core}/lazy_array.rb +9 -3
- data/lib/openhab/core/profile_factory.rb +132 -0
- data/lib/openhab/core/provider.rb +230 -0
- data/lib/openhab/core/proxy.rb +130 -0
- data/lib/openhab/core/registry.rb +40 -0
- data/lib/openhab/core/rules/module.rb +26 -0
- data/lib/openhab/core/rules/provider.rb +25 -0
- data/lib/openhab/core/rules/registry.rb +76 -0
- data/lib/openhab/core/rules/rule.rb +150 -0
- data/lib/openhab/core/rules.rb +25 -0
- data/lib/openhab/core/script_handling.rb +78 -20
- data/lib/openhab/core/things/channel.rb +48 -0
- data/lib/openhab/core/things/channel_uid.rb +51 -0
- data/lib/openhab/core/things/item_channel_link.rb +33 -0
- data/lib/openhab/core/things/links/provider.rb +78 -0
- data/lib/openhab/core/things/profile_callback.rb +52 -0
- data/lib/openhab/core/things/provider.rb +29 -0
- data/lib/openhab/core/things/proxy.rb +87 -0
- data/lib/openhab/core/things/registry.rb +73 -0
- data/lib/openhab/core/things/thing.rb +194 -0
- data/lib/openhab/core/things.rb +22 -0
- data/lib/openhab/core/timer.rb +148 -0
- data/lib/openhab/{dsl → core}/types/comparable_type.rb +5 -3
- data/lib/openhab/{dsl → core}/types/date_time_type.rb +55 -127
- data/lib/openhab/{dsl → core}/types/decimal_type.rb +50 -48
- data/lib/openhab/{dsl → core}/types/hsb_type.rb +35 -83
- data/lib/openhab/core/types/increase_decrease_type.rb +34 -0
- data/lib/openhab/core/types/next_previous_type.rb +34 -0
- data/lib/openhab/{dsl → core}/types/numeric_type.rb +20 -7
- data/lib/openhab/core/types/on_off_type.rb +46 -0
- data/lib/openhab/core/types/open_closed_type.rb +41 -0
- data/lib/openhab/{dsl → core}/types/percent_type.rb +19 -20
- data/lib/openhab/core/types/play_pause_type.rb +38 -0
- data/lib/openhab/core/types/point_type.rb +117 -0
- data/lib/openhab/core/types/quantity_type.rb +325 -0
- data/lib/openhab/core/types/raw_type.rb +26 -0
- data/lib/openhab/core/types/refresh_type.rb +27 -0
- data/lib/openhab/core/types/rewind_fastforward_type.rb +38 -0
- data/lib/openhab/core/types/stop_move_type.rb +34 -0
- data/lib/openhab/{dsl → core}/types/string_type.rb +17 -28
- data/lib/openhab/{dsl → core}/types/type.rb +42 -40
- data/lib/openhab/core/types/un_def_type.rb +38 -0
- data/lib/openhab/core/types/up_down_type.rb +50 -0
- data/lib/openhab/core/types.rb +82 -0
- data/lib/openhab/{dsl → core}/uid.rb +4 -23
- data/lib/openhab/core/value_cache.rb +188 -0
- data/lib/openhab/core.rb +98 -0
- data/lib/openhab/core_ext/between.rb +32 -0
- data/lib/openhab/core_ext/ephemeris.rb +53 -0
- data/lib/openhab/core_ext/java/class.rb +34 -0
- data/lib/openhab/core_ext/java/duration.rb +142 -0
- data/lib/openhab/core_ext/java/list.rb +436 -0
- data/lib/openhab/core_ext/java/local_date.rb +104 -0
- data/lib/openhab/core_ext/java/local_time.rb +118 -0
- data/lib/openhab/core_ext/java/map.rb +66 -0
- data/lib/openhab/core_ext/java/month.rb +71 -0
- data/lib/openhab/core_ext/java/month_day.rb +119 -0
- data/lib/openhab/core_ext/java/period.rb +103 -0
- data/lib/openhab/core_ext/java/temporal_amount.rb +34 -0
- data/lib/openhab/core_ext/java/time.rb +62 -0
- data/lib/openhab/core_ext/java/unit.rb +15 -0
- data/lib/openhab/core_ext/java/zoned_date_time.rb +213 -0
- data/lib/openhab/core_ext/ruby/array.rb +21 -0
- data/lib/openhab/core_ext/ruby/date.rb +96 -0
- data/lib/openhab/core_ext/ruby/date_time.rb +55 -0
- data/lib/openhab/core_ext/ruby/module.rb +15 -0
- data/lib/openhab/core_ext/ruby/numeric.rb +195 -0
- data/lib/openhab/core_ext/ruby/range.rb +70 -0
- data/lib/openhab/core_ext/ruby/symbol.rb +7 -0
- data/lib/openhab/core_ext/ruby/time.rb +108 -0
- data/lib/openhab/core_ext.rb +18 -0
- data/lib/openhab/dsl/debouncer.rb +259 -0
- data/lib/openhab/dsl/events/watch_event.rb +18 -0
- data/lib/openhab/dsl/events.rb +9 -0
- data/lib/openhab/dsl/gems.rb +1 -1
- data/lib/openhab/dsl/items/builder.rb +578 -0
- data/lib/openhab/dsl/items/ensure.rb +73 -82
- data/lib/openhab/dsl/items/timed_command.rb +214 -159
- data/lib/openhab/dsl/rules/automation_rule.rb +126 -115
- data/lib/openhab/dsl/rules/builder.rb +1935 -0
- data/lib/openhab/dsl/rules/guard.rb +51 -114
- data/lib/openhab/dsl/rules/name_inference.rb +66 -25
- data/lib/openhab/dsl/rules/property.rb +48 -75
- data/lib/openhab/dsl/rules/rule_triggers.rb +22 -27
- data/lib/openhab/dsl/rules/terse.rb +58 -14
- data/lib/openhab/dsl/rules/triggers/changed.rb +48 -94
- data/lib/openhab/dsl/rules/triggers/channel.rb +9 -40
- data/lib/openhab/dsl/rules/triggers/command.rb +14 -63
- data/lib/openhab/dsl/rules/triggers/conditions/duration.rb +34 -69
- data/lib/openhab/dsl/rules/triggers/conditions/proc.rb +6 -14
- data/lib/openhab/dsl/rules/triggers/cron/cron.rb +48 -82
- data/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb +30 -47
- data/lib/openhab/dsl/rules/triggers/trigger.rb +7 -28
- data/lib/openhab/dsl/rules/triggers/updated.rb +21 -45
- data/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb +257 -102
- data/lib/openhab/dsl/rules/triggers.rb +12 -0
- data/lib/openhab/dsl/rules.rb +8 -0
- data/lib/openhab/dsl/things/builder.rb +299 -0
- data/lib/openhab/{core → dsl}/thread_local.rb +27 -17
- data/lib/openhab/dsl/timer_manager.rb +204 -0
- data/lib/openhab/dsl/version.rb +9 -0
- data/lib/openhab/dsl.rb +979 -0
- data/lib/openhab/log.rb +355 -0
- data/lib/openhab/osgi.rb +68 -0
- data/lib/openhab/rspec/configuration.rb +56 -0
- data/lib/openhab/rspec/example_group.rb +132 -0
- data/lib/openhab/rspec/helpers.rb +458 -0
- data/lib/openhab/rspec/hooks.rb +113 -0
- data/lib/openhab/rspec/jruby.rb +46 -0
- data/lib/openhab/rspec/karaf.rb +851 -0
- data/lib/openhab/rspec/mocks/bundle_install_support.rb +25 -0
- data/lib/openhab/rspec/mocks/bundle_resolver.rb +30 -0
- data/lib/openhab/rspec/mocks/event_admin.rb +146 -0
- data/lib/openhab/rspec/mocks/instance_method_stasher.rb +22 -0
- data/lib/openhab/rspec/mocks/persistence_service.rb +155 -0
- data/lib/openhab/rspec/mocks/safe_caller.rb +40 -0
- data/lib/openhab/rspec/mocks/space.rb +23 -0
- data/lib/openhab/rspec/mocks/synchronous_executor.rb +63 -0
- data/lib/openhab/rspec/mocks/thing_handler.rb +76 -0
- data/lib/openhab/rspec/mocks/timer.rb +134 -0
- data/lib/openhab/rspec/openhab/core/actions.rb +38 -0
- data/lib/openhab/rspec/openhab/core/items/proxy.rb +15 -0
- data/lib/openhab/rspec/openhab/core/things/proxy.rb +27 -0
- data/lib/openhab/rspec/shell.rb +31 -0
- data/lib/openhab/rspec/suspend_rules.rb +50 -0
- data/lib/openhab/rspec.rb +26 -0
- data/lib/openhab/yard/base_helper.rb +19 -0
- data/lib/openhab/yard/cli/stats.rb +23 -0
- data/lib/openhab/yard/code_objects/group_object.rb +23 -0
- data/lib/openhab/yard/code_objects/java/base.rb +31 -0
- data/lib/openhab/yard/code_objects/java/class_object.rb +11 -0
- data/lib/openhab/yard/code_objects/java/field_object.rb +15 -0
- data/lib/openhab/yard/code_objects/java/interface_object.rb +15 -0
- data/lib/openhab/yard/code_objects/java/package_object.rb +11 -0
- data/lib/openhab/yard/code_objects/java/proxy.rb +23 -0
- data/lib/openhab/yard/coderay.rb +17 -0
- data/lib/openhab/yard/handlers/jruby/base.rb +58 -0
- data/lib/openhab/yard/handlers/jruby/class_handler.rb +18 -0
- data/lib/openhab/yard/handlers/jruby/constant_handler.rb +18 -0
- data/lib/openhab/yard/handlers/jruby/java_import_handler.rb +30 -0
- data/lib/openhab/yard/handlers/jruby/mixin_handler.rb +23 -0
- data/lib/openhab/yard/html_helper.rb +78 -0
- data/lib/openhab/yard/markdown_helper.rb +148 -0
- data/lib/openhab/yard/tags/constant_directive.rb +20 -0
- data/lib/openhab/yard/tags/group_directive.rb +24 -0
- data/lib/openhab/yard/tags/library.rb +3 -0
- data/lib/openhab/yard.rb +38 -0
- metadata +475 -106
- data/lib/openhab/core/item_proxy.rb +0 -29
- data/lib/openhab/core/load_path.rb +0 -19
- data/lib/openhab/core/openhab_setup.rb +0 -29
- data/lib/openhab/core/osgi.rb +0 -58
- data/lib/openhab/core/services.rb +0 -24
- data/lib/openhab/dsl/actions.rb +0 -114
- data/lib/openhab/dsl/between.rb +0 -25
- data/lib/openhab/dsl/channel.rb +0 -43
- data/lib/openhab/dsl/dsl.rb +0 -59
- data/lib/openhab/dsl/group.rb +0 -54
- data/lib/openhab/dsl/imports.rb +0 -21
- data/lib/openhab/dsl/items/color_item.rb +0 -76
- data/lib/openhab/dsl/items/comparable_item.rb +0 -62
- data/lib/openhab/dsl/items/contact_item.rb +0 -41
- data/lib/openhab/dsl/items/date_time_item.rb +0 -65
- data/lib/openhab/dsl/items/dimmer_item.rb +0 -65
- data/lib/openhab/dsl/items/generic_item.rb +0 -229
- data/lib/openhab/dsl/items/group_item.rb +0 -127
- data/lib/openhab/dsl/items/item_equality.rb +0 -59
- data/lib/openhab/dsl/items/item_registry.rb +0 -54
- data/lib/openhab/dsl/items/items.rb +0 -109
- data/lib/openhab/dsl/items/location_item.rb +0 -59
- data/lib/openhab/dsl/items/metadata.rb +0 -326
- data/lib/openhab/dsl/items/number_item.rb +0 -17
- data/lib/openhab/dsl/items/numeric_item.rb +0 -87
- data/lib/openhab/dsl/items/persistence.rb +0 -307
- data/lib/openhab/dsl/items/player_item.rb +0 -58
- data/lib/openhab/dsl/items/rollershutter_item.rb +0 -51
- data/lib/openhab/dsl/items/semantics/enumerable.rb +0 -91
- data/lib/openhab/dsl/items/semantics.rb +0 -227
- data/lib/openhab/dsl/items/string_item.rb +0 -51
- data/lib/openhab/dsl/items/switch_item.rb +0 -70
- data/lib/openhab/dsl/monkey_patch/actions/actions.rb +0 -4
- data/lib/openhab/dsl/monkey_patch/actions/script_thing_actions.rb +0 -39
- data/lib/openhab/dsl/monkey_patch/events/events.rb +0 -7
- data/lib/openhab/dsl/monkey_patch/events/item_command.rb +0 -85
- data/lib/openhab/dsl/monkey_patch/events/item_event.rb +0 -28
- data/lib/openhab/dsl/monkey_patch/events/item_state.rb +0 -61
- data/lib/openhab/dsl/monkey_patch/events/item_state_changed.rb +0 -60
- data/lib/openhab/dsl/monkey_patch/events/thing_status_info.rb +0 -33
- data/lib/openhab/dsl/monkey_patch/java/java.rb +0 -4
- data/lib/openhab/dsl/monkey_patch/java/local_time.rb +0 -44
- data/lib/openhab/dsl/monkey_patch/java/time_extensions.rb +0 -50
- data/lib/openhab/dsl/monkey_patch/java/zoned_date_time.rb +0 -45
- data/lib/openhab/dsl/monkey_patch/ruby/number.rb +0 -104
- data/lib/openhab/dsl/monkey_patch/ruby/ruby.rb +0 -6
- data/lib/openhab/dsl/monkey_patch/ruby/string.rb +0 -47
- data/lib/openhab/dsl/monkey_patch/ruby/time.rb +0 -61
- data/lib/openhab/dsl/openhab.rb +0 -30
- data/lib/openhab/dsl/persistence.rb +0 -27
- data/lib/openhab/dsl/rules/item_event.rb +0 -19
- data/lib/openhab/dsl/rules/rule.rb +0 -160
- data/lib/openhab/dsl/rules/rule_config.rb +0 -147
- data/lib/openhab/dsl/rules/triggers/generic.rb +0 -31
- data/lib/openhab/dsl/rules/triggers/triggers.rb +0 -11
- data/lib/openhab/dsl/rules/triggers/watch/watch.rb +0 -81
- data/lib/openhab/dsl/states.rb +0 -89
- data/lib/openhab/dsl/things.rb +0 -147
- data/lib/openhab/dsl/time/month_day.rb +0 -180
- data/lib/openhab/dsl/time/time_of_day.rb +0 -235
- data/lib/openhab/dsl/timers/manager.rb +0 -119
- data/lib/openhab/dsl/timers/reentrant_timer.rb +0 -38
- data/lib/openhab/dsl/timers/timer.rb +0 -132
- data/lib/openhab/dsl/timers.rb +0 -77
- data/lib/openhab/dsl/types/increase_decrease_type.rb +0 -23
- data/lib/openhab/dsl/types/next_previous_type.rb +0 -23
- data/lib/openhab/dsl/types/on_off_type.rb +0 -28
- data/lib/openhab/dsl/types/open_closed_type.rb +0 -29
- data/lib/openhab/dsl/types/play_pause_type.rb +0 -27
- data/lib/openhab/dsl/types/point_type.rb +0 -180
- data/lib/openhab/dsl/types/quantity_type.rb +0 -265
- data/lib/openhab/dsl/types/refresh_type.rb +0 -18
- data/lib/openhab/dsl/types/rewind_fastforward_type.rb +0 -33
- data/lib/openhab/dsl/types/stop_move_type.rb +0 -23
- data/lib/openhab/dsl/types/types.rb +0 -83
- data/lib/openhab/dsl/types/un_def_type.rb +0 -22
- data/lib/openhab/dsl/types/up_down_type.rb +0 -32
- data/lib/openhab/dsl/units.rb +0 -45
- data/lib/openhab/log/configuration.rb +0 -21
- data/lib/openhab/log/logger.rb +0 -282
- data/lib/openhab/version.rb +0 -9
- data/lib/openhab.rb +0 -36
|
@@ -3,21 +3,65 @@
|
|
|
3
3
|
module OpenHAB
|
|
4
4
|
module DSL
|
|
5
5
|
module Rules
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
# If you have a single trigger and execution block, you can use a terse rule:
|
|
7
|
+
# All parameters to the trigger are passed through, and an optional `name:` parameter is added.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# changed TestSwitch do |event|
|
|
11
|
+
# logger.info("TestSwitch changed to #{event.state}")
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# received_command TestSwitch, name: "My Test Switch Rule", command: ON do
|
|
16
|
+
# logger.info("TestSwitch received command ON")
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
module Terse
|
|
20
|
+
class << self
|
|
21
|
+
# @!visibility private
|
|
22
|
+
# @!macro def_terse_rule
|
|
23
|
+
# @!method $1(*args, name :nil, id: nil, on_load: false, **kwargs, &block)
|
|
24
|
+
# Create a new rule with a $1 trigger.
|
|
25
|
+
# @param name [String] The name for the rule.
|
|
26
|
+
# @param id [String] The ID for the rule.
|
|
27
|
+
# @param on_load [true, false] If the rule should _also_ trigger immediately when the script loads.
|
|
28
|
+
# @yield The execution block for the rule.
|
|
29
|
+
# @return [void]
|
|
30
|
+
# @see BuilderDSL#$1
|
|
31
|
+
def def_terse_rule(trigger)
|
|
32
|
+
class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
|
33
|
+
def #{trigger}(*args, name: nil, id: nil, on_load: false, **kwargs, &block) # def changed(*args, name: nil, id: nil, on_load: false, **kwargs, &block)
|
|
34
|
+
raise ArgumentError, "Block is required" unless block # raise ArgumentError, "Block is required" unless block
|
|
35
|
+
#
|
|
36
|
+
id ||= NameInference.infer_rule_id_from_block(block) # id ||= NameInference.infer_rule_id_from_block(block)
|
|
37
|
+
script = block.source rescue nil # script = block.source rescue nil
|
|
38
|
+
caller_binding = block.binding # caller_binding = block.binding
|
|
39
|
+
rule name, id: id, script: script, binding: caller_binding do # rule name, id: id, script: script, binding: caller_binding do
|
|
40
|
+
self.on_load if on_load # self.on_load if on_load
|
|
41
|
+
#{trigger}(*args, **kwargs) # changed(*args, **kwargs)
|
|
42
|
+
run(&block) # run(&block)
|
|
43
|
+
end # end
|
|
44
|
+
end # end
|
|
45
|
+
module_function #{trigger.inspect} # module_function :changed
|
|
46
|
+
RUBY
|
|
47
|
+
end
|
|
20
48
|
end
|
|
49
|
+
|
|
50
|
+
def_terse_rule(:changed)
|
|
51
|
+
def_terse_rule(:channel)
|
|
52
|
+
def_terse_rule(:channel_linked)
|
|
53
|
+
def_terse_rule(:channel_unlinked)
|
|
54
|
+
def_terse_rule(:cron)
|
|
55
|
+
def_terse_rule(:every)
|
|
56
|
+
def_terse_rule(:item_added)
|
|
57
|
+
def_terse_rule(:item_updated)
|
|
58
|
+
def_terse_rule(:item_removed)
|
|
59
|
+
def_terse_rule(:on_start)
|
|
60
|
+
def_terse_rule(:received_command)
|
|
61
|
+
def_terse_rule(:thing_added)
|
|
62
|
+
def_terse_rule(:thing_updated)
|
|
63
|
+
def_terse_rule(:thing_removed)
|
|
64
|
+
def_terse_rule(:updated)
|
|
21
65
|
end
|
|
22
66
|
end
|
|
23
67
|
end
|
|
@@ -1,80 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative 'trigger'
|
|
3
|
+
require_relative "conditions/duration"
|
|
4
|
+
require_relative "conditions/proc"
|
|
5
|
+
require_relative "trigger"
|
|
7
6
|
|
|
8
7
|
module OpenHAB
|
|
9
8
|
module DSL
|
|
10
9
|
module Rules
|
|
11
|
-
#
|
|
12
|
-
# Module for changed triggers
|
|
13
|
-
#
|
|
14
|
-
|
|
15
10
|
module Triggers
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
#
|
|
19
|
-
# Creates a trigger item, group and thing changed
|
|
20
|
-
#
|
|
21
|
-
# @param [Object] items array of objects to create trigger for
|
|
22
|
-
# @param [to] to state for object to change for
|
|
23
|
-
# @param [from] from <description>
|
|
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
|
|
26
|
-
#
|
|
27
|
-
# @return [Trigger] OpenHAB trigger
|
|
28
|
-
#
|
|
29
|
-
def changed(*items, to: nil, from: nil, for: nil, attach: nil)
|
|
30
|
-
changed = Changed.new(rule_triggers: @rule_triggers)
|
|
31
|
-
# for is a reserved word in ruby, so use local_variable_get :for
|
|
32
|
-
duration = binding.local_variable_get(:for)
|
|
33
|
-
|
|
34
|
-
flattened_items = Changed.flatten_items(items)
|
|
35
|
-
@ruby_triggers << [:changed, flattened_items, { to: to, from: from, duration: duration }]
|
|
36
|
-
flattened_items.map do |item|
|
|
37
|
-
logger.trace("Creating changed trigger for entity(#{item}), to(#{to}), from(#{from})")
|
|
38
|
-
|
|
39
|
-
Changed.each_state(from, to) do |from_state, to_state|
|
|
40
|
-
changed.trigger(item: item, from: from_state, to: to_state, duration: duration, attach: attach)
|
|
41
|
-
end
|
|
42
|
-
end.flatten
|
|
43
|
-
end
|
|
44
|
-
|
|
11
|
+
# @!visibility private
|
|
45
12
|
#
|
|
46
13
|
# Creates changed triggers
|
|
47
14
|
#
|
|
48
15
|
class Changed < Trigger
|
|
49
|
-
#
|
|
50
|
-
# Run block for each state combination
|
|
51
|
-
#
|
|
52
|
-
# @param [Item State, Array<Item State>] from state to restrict trigger to
|
|
53
|
-
# @param [Item State, Array<Item State>] to state to restrict trigger to
|
|
54
|
-
#
|
|
55
|
-
# @yieldparam [Item State] from_state from state
|
|
56
|
-
# @yieldparam [Item State] to_state to state
|
|
57
|
-
#
|
|
58
|
-
# @return [Array] array of block return values
|
|
59
|
-
#
|
|
60
|
-
def self.each_state(from, to)
|
|
61
|
-
[to].flatten.each_with_object([]) do |to_state, agg|
|
|
62
|
-
[from].flatten.each do |from_state|
|
|
63
|
-
agg.push(yield(from_state, to_state))
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
16
|
#
|
|
69
17
|
# Create the trigger
|
|
70
18
|
#
|
|
71
|
-
# @param [
|
|
72
|
-
# @param [
|
|
73
|
-
# @param [
|
|
74
|
-
# @param [
|
|
19
|
+
# @param [Core::Items::Item, Core::Items::GroupItem::Members] item item to create trigger for
|
|
20
|
+
# @param [Core::Types::State, Array<Core::Types::State>, Range, Proc] from state to restrict trigger to
|
|
21
|
+
# @param [Core::Types::State, Array<Core::Types::State>, Range, Proc] to state to restrict trigger to
|
|
22
|
+
# @param [Duration, nil] duration duration to delay trigger until to state is met
|
|
75
23
|
# @param [Object] attach object to be attached to the trigger
|
|
76
24
|
#
|
|
77
|
-
# @return [Trigger]
|
|
25
|
+
# @return [org.openhab.core.automation.Trigger] openHAB triggers
|
|
78
26
|
#
|
|
79
27
|
def trigger(item:, from:, to:, duration:, attach:)
|
|
80
28
|
if duration
|
|
@@ -91,24 +39,26 @@ module OpenHAB
|
|
|
91
39
|
private
|
|
92
40
|
|
|
93
41
|
# @return [String] A thing status Change trigger
|
|
94
|
-
THING_CHANGE =
|
|
42
|
+
THING_CHANGE = "core.ThingStatusChangeTrigger"
|
|
95
43
|
|
|
96
44
|
# @return [String] An item state change trigger
|
|
97
|
-
ITEM_STATE_CHANGE =
|
|
45
|
+
ITEM_STATE_CHANGE = "core.ItemStateChangeTrigger"
|
|
98
46
|
|
|
99
47
|
# @return [String] A group state change trigger for items in the group
|
|
100
|
-
GROUP_STATE_CHANGE =
|
|
48
|
+
GROUP_STATE_CHANGE = "core.GroupStateChangeTrigger"
|
|
101
49
|
|
|
102
50
|
#
|
|
103
51
|
# Create a TriggerDelay for for an item or group that is changed for a specific duration
|
|
104
52
|
#
|
|
105
|
-
# @param [
|
|
106
|
-
# @param [
|
|
107
|
-
# @param [
|
|
108
|
-
#
|
|
53
|
+
# @param [Core::Items::Item, Core::Items::GroupItem::Members] item to create trigger delay for
|
|
54
|
+
# @param [Duration] duration to delay trigger for until condition is met
|
|
55
|
+
# @param [Core::Types::State, Array<Core::Types::State>, Range, Proc] to
|
|
56
|
+
# State item or group needs to change to
|
|
57
|
+
# @param [Core::Types::State, Array<Core::Types::State>, Range, Proc] from
|
|
58
|
+
# State item or group needs to be coming from
|
|
109
59
|
# @param [Object] attach object to be attached to the trigger
|
|
110
60
|
#
|
|
111
|
-
# @return [Trigger]
|
|
61
|
+
# @return [org.openhab.core.automation.Trigger]
|
|
112
62
|
#
|
|
113
63
|
def wait_trigger(item:, duration:, to: nil, from: nil, attach: nil)
|
|
114
64
|
item_name = item.respond_to?(:name) ? item.name : item.to_s
|
|
@@ -120,11 +70,11 @@ module OpenHAB
|
|
|
120
70
|
|
|
121
71
|
#
|
|
122
72
|
# Creates a trigger with a range condition on either 'from' or 'to' field
|
|
123
|
-
# @param [
|
|
124
|
-
# @param [
|
|
125
|
-
# @param [
|
|
73
|
+
# @param [Core::Items::Item, Core::Items::GroupItem::Members] item to create changed trigger on
|
|
74
|
+
# @param [Range] from state to restrict trigger to
|
|
75
|
+
# @param [Range] to state restrict trigger to
|
|
126
76
|
# @param [Object] attach object to be attached to the trigger
|
|
127
|
-
# @return [Trigger]
|
|
77
|
+
# @return [org.openhab.core.automation.Trigger]
|
|
128
78
|
#
|
|
129
79
|
def range_trigger(item:, from:, to:, attach:)
|
|
130
80
|
from, to = Conditions::Proc.range_procs(from, to)
|
|
@@ -133,17 +83,17 @@ module OpenHAB
|
|
|
133
83
|
|
|
134
84
|
#
|
|
135
85
|
# Creates a trigger with a proc condition on either 'from' or 'to' field
|
|
136
|
-
# @param [
|
|
137
|
-
# @param [
|
|
138
|
-
# @param [
|
|
86
|
+
# @param [Core::Items::Item, Core::Items::GroupItem::Members] item to create changed trigger on
|
|
87
|
+
# @param [Proc] from state to restrict trigger to
|
|
88
|
+
# @param [Proc] to state restrict trigger to
|
|
139
89
|
# @param [Object] attach object to be attached to the trigger
|
|
140
|
-
# @return [Trigger]
|
|
90
|
+
# @return [org.openhab.core.automation.Trigger]
|
|
141
91
|
#
|
|
142
92
|
def proc_trigger(item:, from:, to:, attach:)
|
|
143
93
|
# swap from/to w/ nil if from/to is a proc
|
|
144
94
|
# rubocop:disable Style/ParallelAssignment
|
|
145
|
-
from_proc, from = from, nil if from.is_a?
|
|
146
|
-
to_proc, to = to, nil if to.is_a?
|
|
95
|
+
from_proc, from = from, nil if from.is_a?(Proc)
|
|
96
|
+
to_proc, to = to, nil if to.is_a?(Proc)
|
|
147
97
|
# rubocop:enable Style/ParallelAssignment
|
|
148
98
|
conditions = Conditions::Proc.new(to: to_proc, from: from_proc)
|
|
149
99
|
changed_trigger(item: item, from: from, to: to, attach: attach, conditions: conditions)
|
|
@@ -152,17 +102,21 @@ module OpenHAB
|
|
|
152
102
|
#
|
|
153
103
|
# Create a changed trigger
|
|
154
104
|
#
|
|
155
|
-
# @param [
|
|
156
|
-
# @param [
|
|
157
|
-
# @param [
|
|
105
|
+
# @param [Core::Items::Item, Core::Items::GroupItem::Members] item to create changed trigger on
|
|
106
|
+
# @param [Core::Items::State, Array<Core::Items::State>] from state to restrict trigger to
|
|
107
|
+
# @param [Core::Items::State, Array<Core::Items::State>] to state restrict trigger to
|
|
158
108
|
# @param [Object] attach object to be attached to the trigger
|
|
109
|
+
# @return [org.openhab.core.automation.Trigger]
|
|
159
110
|
#
|
|
160
111
|
def changed_trigger(item:, from:, to:, attach: nil, conditions: nil)
|
|
161
112
|
type, config = case item
|
|
162
|
-
when
|
|
163
|
-
|
|
164
|
-
when Thing
|
|
165
|
-
|
|
113
|
+
when GroupItem::Members
|
|
114
|
+
group(group: item, from: from, to: to)
|
|
115
|
+
when Core::Things::Thing,
|
|
116
|
+
Core::Things::ThingUID
|
|
117
|
+
thing(thing: item, from: from, to: to)
|
|
118
|
+
else
|
|
119
|
+
item(item: item, from: from, to: to)
|
|
166
120
|
end
|
|
167
121
|
append_trigger(type: type, config: config, attach: attach, conditions: conditions)
|
|
168
122
|
end
|
|
@@ -170,7 +124,7 @@ module OpenHAB
|
|
|
170
124
|
#
|
|
171
125
|
# Create a changed trigger for a thing
|
|
172
126
|
#
|
|
173
|
-
# @param [Thing] thing to detected changed states on
|
|
127
|
+
# @param [Core::Things::Thing] thing to detected changed states on
|
|
174
128
|
# @param [String] from state to restrict trigger to
|
|
175
129
|
# @param [String] to state to restrict trigger to
|
|
176
130
|
#
|
|
@@ -192,16 +146,16 @@ module OpenHAB
|
|
|
192
146
|
# second element is a Hash configuring trigger
|
|
193
147
|
#
|
|
194
148
|
def item(item:, from:, to:)
|
|
195
|
-
config = {
|
|
196
|
-
config[
|
|
197
|
-
config[
|
|
149
|
+
config = { "itemName" => item.name }
|
|
150
|
+
config["state"] = to.to_s if to
|
|
151
|
+
config["previousState"] = from.to_s if from
|
|
198
152
|
[ITEM_STATE_CHANGE, config]
|
|
199
153
|
end
|
|
200
154
|
|
|
201
155
|
#
|
|
202
156
|
# Create a changed trigger for group items
|
|
203
157
|
#
|
|
204
|
-
# @param [
|
|
158
|
+
# @param [GroupItem] group to detected changed states on
|
|
205
159
|
# @param [String] from state to restrict trigger to
|
|
206
160
|
# @param [String] to to restrict trigger to
|
|
207
161
|
#
|
|
@@ -209,9 +163,9 @@ module OpenHAB
|
|
|
209
163
|
# second element is a Hash configuring trigger
|
|
210
164
|
#
|
|
211
165
|
def group(group:, from:, to:)
|
|
212
|
-
config = {
|
|
213
|
-
config[
|
|
214
|
-
config[
|
|
166
|
+
config = { "groupName" => group.name }
|
|
167
|
+
config["state"] = to.to_s if to
|
|
168
|
+
config["previousState"] = from.to_s if from
|
|
215
169
|
[GROUP_STATE_CHANGE, config]
|
|
216
170
|
end
|
|
217
171
|
end
|
|
@@ -1,49 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require 'openhab/dsl/things'
|
|
5
|
-
require_relative 'trigger'
|
|
3
|
+
require_relative "trigger"
|
|
6
4
|
|
|
7
5
|
module OpenHAB
|
|
8
6
|
module DSL
|
|
9
7
|
module Rules
|
|
10
|
-
#
|
|
11
|
-
# Channel triggers
|
|
12
|
-
#
|
|
13
8
|
module Triggers
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#
|
|
17
|
-
# Creates a channel trigger
|
|
18
|
-
#
|
|
19
|
-
# @param [String, Channel, ChannelUID, Array<String, Channel, ChannelUID>] channels
|
|
20
|
-
# channels to create triggers for in form of 'binding_id:type_id:thing_id#channel_id'
|
|
21
|
-
# or 'channel_id' if thing is provided
|
|
22
|
-
# @param [String, Thing, ThingUID, Array<String, Thing, ThingUID>] thing
|
|
23
|
-
# thing(s) to create trigger for if not specified with the channel
|
|
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
|
|
26
|
-
#
|
|
27
|
-
def channel(*channels, thing: nil, triggered: nil, attach: nil)
|
|
28
|
-
channel_trigger = Channel.new(rule_triggers: @rule_triggers)
|
|
29
|
-
flattened_channels = Channel.channels(channels: channels, thing: thing)
|
|
30
|
-
triggers = [triggered].flatten
|
|
31
|
-
@ruby_triggers << [:channel, flattened_channels, { triggers: triggers }]
|
|
32
|
-
flattened_channels.each do |channel|
|
|
33
|
-
triggers.each do |trigger|
|
|
34
|
-
channel_trigger.trigger(channel: channel, trigger: trigger, attach: attach)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
9
|
+
# @!visibility private
|
|
39
10
|
#
|
|
40
11
|
# Creates channel triggers
|
|
41
12
|
#
|
|
42
13
|
class Channel < Trigger
|
|
43
|
-
include OpenHAB::Log
|
|
44
|
-
|
|
45
14
|
# @return [String] A channel event trigger
|
|
46
|
-
CHANNEL_EVENT =
|
|
15
|
+
CHANNEL_EVENT = "core.ChannelEventTrigger"
|
|
47
16
|
|
|
48
17
|
#
|
|
49
18
|
# Get an enumerator over the product of the channels and things and map them to a channel id
|
|
@@ -51,7 +20,7 @@ module OpenHAB
|
|
|
51
20
|
# @param [Object] thing to combine with channels and iterate over
|
|
52
21
|
# @return [Enumerable] enumerable channel ids to trigger on
|
|
53
22
|
def self.channels(channels:, thing:)
|
|
54
|
-
logger.
|
|
23
|
+
logger.trace "Creating Channel/Thing Pairs for channels #{channels.inspect} and things #{thing.inspect}"
|
|
55
24
|
channels.flatten.product([thing].flatten)
|
|
56
25
|
.map { |channel_thing| channel_id(*channel_thing) }
|
|
57
26
|
end
|
|
@@ -63,8 +32,8 @@ module OpenHAB
|
|
|
63
32
|
#
|
|
64
33
|
def self.channel_id(channel, thing)
|
|
65
34
|
channel = channel.uid if channel.is_a?(org.openhab.core.thing.Channel)
|
|
66
|
-
thing = thing.uid if thing.is_a?(Thing)
|
|
67
|
-
[thing, channel].compact.join(
|
|
35
|
+
thing = thing.uid if thing.is_a?(Core::Things::Thing)
|
|
36
|
+
[thing, channel].compact.join(":")
|
|
68
37
|
end
|
|
69
38
|
|
|
70
39
|
#
|
|
@@ -76,9 +45,9 @@ module OpenHAB
|
|
|
76
45
|
#
|
|
77
46
|
#
|
|
78
47
|
def trigger(channel:, trigger:, attach:)
|
|
79
|
-
config = {
|
|
80
|
-
config[
|
|
81
|
-
logger.
|
|
48
|
+
config = { "channelUID" => channel }
|
|
49
|
+
config["event"] = trigger.to_s unless trigger.nil?
|
|
50
|
+
logger.trace "Creating Channel Trigger for channels #{channel.inspect} and config #{config.inspect}"
|
|
82
51
|
append_trigger(type: CHANNEL_EVENT, config: config, attach: attach)
|
|
83
52
|
end
|
|
84
53
|
end
|
|
@@ -1,66 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require_relative 'trigger'
|
|
3
|
+
require_relative "trigger"
|
|
5
4
|
|
|
6
5
|
module OpenHAB
|
|
7
6
|
module DSL
|
|
8
7
|
module Rules
|
|
9
|
-
#
|
|
10
|
-
# Module holds rule triggers
|
|
11
|
-
#
|
|
12
8
|
module Triggers
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
#
|
|
16
|
-
# Create a trigger for when an item or group receives a command
|
|
17
|
-
#
|
|
18
|
-
# The commands/commands parameters are replicated for DSL fluency
|
|
19
|
-
#
|
|
20
|
-
# @param [Array] items Array of items to create trigger for
|
|
21
|
-
# @param [Array] command commands to match for trigger
|
|
22
|
-
# @param [Array] commands commands to match for trigger
|
|
23
|
-
# @param [Object] attach object to be attached to the trigger
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
def received_command(*items, command: nil, commands: nil, attach: nil)
|
|
27
|
-
command_trigger = Command.new(rule_triggers: @rule_triggers)
|
|
28
|
-
|
|
29
|
-
# Combine command and commands, doing union so only a single nil will be in the combined array.
|
|
30
|
-
combined_commands = Command.combine_commands(command: command, commands: commands)
|
|
31
|
-
flattened_items = Command.flatten_items(items)
|
|
32
|
-
@ruby_triggers << [:received_command, flattened_items, { command: combined_commands }]
|
|
33
|
-
|
|
34
|
-
flattened_items.map do |item|
|
|
35
|
-
combined_commands.map do |cmd|
|
|
36
|
-
logger.states 'Creating received command trigger', item: item, command: cmd
|
|
37
|
-
|
|
38
|
-
command_trigger.trigger(item: item, command: cmd, attach: attach)
|
|
39
|
-
end
|
|
40
|
-
end.flatten
|
|
41
|
-
end
|
|
42
|
-
|
|
9
|
+
# @!visibility private
|
|
43
10
|
#
|
|
44
11
|
# Creates command triggers
|
|
45
12
|
#
|
|
46
13
|
class Command < Trigger
|
|
47
|
-
# Combine command and commands into a single array
|
|
48
|
-
#
|
|
49
|
-
# @param [Array] command list of commands to trigger on
|
|
50
|
-
# @param [Array] commands list of commands to trigger on
|
|
51
|
-
#
|
|
52
|
-
# @return [Array] Combined flattened and compacted list of commands
|
|
53
|
-
#
|
|
54
|
-
def self.combine_commands(command:, commands:)
|
|
55
|
-
combined_commands = ([command] | [commands]).flatten
|
|
56
|
-
|
|
57
|
-
# If either command or commands has a value and one is nil, we need to remove nil from the array.
|
|
58
|
-
# If it is only now a single nil value, we leave the nil in place, so that we create a trigger
|
|
59
|
-
# That isn't looking for a specific command.
|
|
60
|
-
combined_commands = combined_commands.compact unless combined_commands.all?(&:nil?)
|
|
61
|
-
combined_commands
|
|
62
|
-
end
|
|
63
|
-
|
|
64
14
|
#
|
|
65
15
|
# Create a received command trigger
|
|
66
16
|
#
|
|
@@ -68,7 +18,7 @@ module OpenHAB
|
|
|
68
18
|
# @param [Object] command to check against
|
|
69
19
|
# @param [Object] attach object to be attached to the trigger
|
|
70
20
|
#
|
|
71
|
-
# @return [Trigger]
|
|
21
|
+
# @return [org.openhab.core.automation.Trigger]
|
|
72
22
|
#
|
|
73
23
|
def trigger(item:, command:, attach:)
|
|
74
24
|
case command
|
|
@@ -81,9 +31,9 @@ module OpenHAB
|
|
|
81
31
|
#
|
|
82
32
|
# Creates a trigger with a range condition on the 'command' field
|
|
83
33
|
# @param [Object] item to create changed trigger on
|
|
84
|
-
# @param [
|
|
34
|
+
# @param [Range] command to restrict trigger to
|
|
85
35
|
# @param [Object] attach object to be attached to the trigger
|
|
86
|
-
# @return [Trigger]
|
|
36
|
+
# @return [org.openhab.core.automation.Trigger]
|
|
87
37
|
#
|
|
88
38
|
def range_trigger(item:, command:, attach:)
|
|
89
39
|
command_range, * = Conditions::Proc.range_procs(command)
|
|
@@ -95,7 +45,7 @@ module OpenHAB
|
|
|
95
45
|
# @param [Object] item to create changed trigger on
|
|
96
46
|
# @param [Object] command to restrict trigger to
|
|
97
47
|
# @param [Object] attach object to be attached to the trigger
|
|
98
|
-
# @return [Trigger]
|
|
48
|
+
# @return [org.openhab.core.automation.Trigger]
|
|
99
49
|
#
|
|
100
50
|
def proc_trigger(item:, command:, attach:)
|
|
101
51
|
conditions = Conditions::Proc.new(command: command)
|
|
@@ -108,24 +58,25 @@ module OpenHAB
|
|
|
108
58
|
# @param [Object] item to create trigger for
|
|
109
59
|
# @param [String] command to create trigger for
|
|
110
60
|
# @param [Object] attach object to be attached to the trigger
|
|
61
|
+
# @return [org.openhab.core.automation.Trigger]
|
|
111
62
|
#
|
|
112
63
|
def command_trigger(item:, command:, attach: nil, conditions: nil)
|
|
113
|
-
type, config = if item.is_a?
|
|
64
|
+
type, config = if item.is_a?(GroupItem::Members)
|
|
114
65
|
group(group: item)
|
|
115
66
|
else
|
|
116
67
|
item(item: item)
|
|
117
68
|
end
|
|
118
|
-
config[
|
|
69
|
+
config["command"] = command.to_s unless command.nil?
|
|
119
70
|
append_trigger(type: type, config: config, attach: attach, conditions: conditions)
|
|
120
71
|
end
|
|
121
72
|
|
|
122
73
|
private
|
|
123
74
|
|
|
124
75
|
# @return [String] item command trigger
|
|
125
|
-
ITEM_COMMAND =
|
|
76
|
+
ITEM_COMMAND = "core.ItemCommandTrigger"
|
|
126
77
|
|
|
127
78
|
# @return [String] A group command trigger for items in the group
|
|
128
|
-
GROUP_COMMAND =
|
|
79
|
+
GROUP_COMMAND = "core.GroupCommandTrigger"
|
|
129
80
|
|
|
130
81
|
#
|
|
131
82
|
# Create trigger for item commands
|
|
@@ -136,19 +87,19 @@ module OpenHAB
|
|
|
136
87
|
# second element is trigger type
|
|
137
88
|
#
|
|
138
89
|
def item(item:)
|
|
139
|
-
[ITEM_COMMAND, {
|
|
90
|
+
[ITEM_COMMAND, { "itemName" => item.name }]
|
|
140
91
|
end
|
|
141
92
|
|
|
142
93
|
#
|
|
143
94
|
# Create trigger for group items
|
|
144
95
|
#
|
|
145
|
-
# @param [
|
|
96
|
+
# @param [GroupItem::Members] group to create trigger for
|
|
146
97
|
#
|
|
147
98
|
# @return [Array<Hash,Trigger>] first element is hash of trigger config properties
|
|
148
99
|
# second element is trigger type
|
|
149
100
|
#
|
|
150
101
|
def group(group:)
|
|
151
|
-
[GROUP_COMMAND, {
|
|
102
|
+
[GROUP_COMMAND, { "groupName" => group.group.name }]
|
|
152
103
|
end
|
|
153
104
|
end
|
|
154
105
|
end
|