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
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'semantics/enumerable'
|
|
4
|
-
|
|
5
|
-
module OpenHAB
|
|
6
|
-
module DSL
|
|
7
|
-
module Items
|
|
8
|
-
# Module for implementing semantics helper methods on [GenericItem]
|
|
9
|
-
#
|
|
10
|
-
# Wraps https://www.openhab.org/javadoc/latest/org/openhab/core/model/script/actions/semantics,
|
|
11
|
-
# as well as adding a few additional convenience methods.
|
|
12
|
-
# Also includes Classes for each semantic tag.
|
|
13
|
-
#
|
|
14
|
-
# Be warned that the Semantic model is stricter than can actually be
|
|
15
|
-
# described by tags and groups on an Item. It makes assumptions that any
|
|
16
|
-
# given item only belongs to one semantic type (Location, Equipment, Point).
|
|
17
|
-
#
|
|
18
|
-
# See https://github.com/openhab/openhab-core/blob/main/bundles/org.openhab.core.semantics/model/SemanticTags.csv
|
|
19
|
-
module Semantics
|
|
20
|
-
# @!visibility private
|
|
21
|
-
# import the actual semantics action
|
|
22
|
-
SemanticsAction = org.openhab.core.model.script.actions.Semantics
|
|
23
|
-
private_constant :SemanticsAction
|
|
24
|
-
|
|
25
|
-
# import all the semantics constants
|
|
26
|
-
[org.openhab.core.semantics.model.point.Points,
|
|
27
|
-
org.openhab.core.semantics.model.property.Properties,
|
|
28
|
-
org.openhab.core.semantics.model.equipment.Equipments,
|
|
29
|
-
org.openhab.core.semantics.model.location.Locations].each do |parent_tag|
|
|
30
|
-
parent_tag.stream.for_each do |tag|
|
|
31
|
-
const_set(tag.simple_name.to_sym, tag.ruby_class)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# put ourself into the global namespace, replacing the action
|
|
36
|
-
::Semantics = self # rubocop:disable Naming/ConstantName
|
|
37
|
-
|
|
38
|
-
# Checks if this Item is a Location
|
|
39
|
-
#
|
|
40
|
-
# This is implemented as checking if the item's semantic_type
|
|
41
|
-
# is a Location. I.e. an Item has a single semantic_type.
|
|
42
|
-
#
|
|
43
|
-
# @return [true, false]
|
|
44
|
-
def location?
|
|
45
|
-
SemanticsAction.location?(self)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# Checks if this Item is an Equipment
|
|
49
|
-
#
|
|
50
|
-
# This is implemented as checking if the item's semantic_type
|
|
51
|
-
# is an Equipment. I.e. an Item has a single semantic_type.
|
|
52
|
-
#
|
|
53
|
-
# @return [true, false]
|
|
54
|
-
def equipment?
|
|
55
|
-
SemanticsAction.equipment?(self)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Checks if this Item is a Point
|
|
59
|
-
#
|
|
60
|
-
# This is implemented as checking if the item's semantic_type
|
|
61
|
-
# is a Point. I.e. an Item has a single semantic_type.
|
|
62
|
-
#
|
|
63
|
-
# @return [true, false]
|
|
64
|
-
def point?
|
|
65
|
-
SemanticsAction.point?(self)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Checks if this Item has any semantic tags
|
|
69
|
-
# @return [true, false]
|
|
70
|
-
def semantic?
|
|
71
|
-
!!semantic_type
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
# Gets the related Location Item of this Item.
|
|
75
|
-
#
|
|
76
|
-
# Checks ancestor groups one level at a time, returning the first Location Item found.
|
|
77
|
-
#
|
|
78
|
-
# @return [GenericItem, nil]
|
|
79
|
-
def location
|
|
80
|
-
SemanticsAction.get_location(self)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# Returns the sub-class of [Location] related to this Item.
|
|
84
|
-
#
|
|
85
|
-
# In other words, the semantic_type of this Item's Location.
|
|
86
|
-
#
|
|
87
|
-
# @return [Class]
|
|
88
|
-
def location_type
|
|
89
|
-
SemanticsAction.get_location_type(self)&.ruby_class
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Gets the related Equipment Item of this Item.
|
|
93
|
-
#
|
|
94
|
-
# Checks ancestor groups one level at a time, returning the first Equipment Item found.
|
|
95
|
-
#
|
|
96
|
-
# @return [GenericItem, nil]
|
|
97
|
-
def equipment
|
|
98
|
-
SemanticsAction.get_equipment(self)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# Returns the sub-class of [Equipment] related to this Item.
|
|
102
|
-
#
|
|
103
|
-
# In other words, the semantic_type of this Item's Equipment.
|
|
104
|
-
#
|
|
105
|
-
# @return [Class]
|
|
106
|
-
def equipment_type
|
|
107
|
-
SemanticsAction.get_equipment_type(self)&.ruby_class
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# Returns the sub-class of [Point] this Item is tagged with.
|
|
111
|
-
#
|
|
112
|
-
# @return [Class]
|
|
113
|
-
def point_type
|
|
114
|
-
SemanticsAction.get_point_type(self)&.ruby_class
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# Returns the sub-class of [Property] this Item is tagged with.
|
|
118
|
-
# @return [Class]
|
|
119
|
-
def property_type
|
|
120
|
-
SemanticsAction.get_property_type(self)&.ruby_class
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
# Returns the sub-class of [Tag] this Item is tagged with.
|
|
124
|
-
#
|
|
125
|
-
# It will only return the first applicable Tag, preferring
|
|
126
|
-
# a sub-class of [Location], [Equipment], or [Point] first,
|
|
127
|
-
# and if none of those are found, looks for a [Property].
|
|
128
|
-
# @return [Class]
|
|
129
|
-
def semantic_type
|
|
130
|
-
SemanticsAction.get_semantic_type(self)&.ruby_class
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
# Return the related Point Items.
|
|
134
|
-
#
|
|
135
|
-
# Searches this Equipment Item for Points that are tagged appropriately.
|
|
136
|
-
#
|
|
137
|
-
# If called on a Point Item, it will automatically search for sibling Points
|
|
138
|
-
# (and remove itself if found).
|
|
139
|
-
#
|
|
140
|
-
# @example Get all points for a TV
|
|
141
|
-
# eGreatTV.points
|
|
142
|
-
# @example Search an Equipment item for its switch
|
|
143
|
-
# eGuestFan.points(Semantics::Switch) # => [GuestFan_Dimmer]
|
|
144
|
-
# @example Search a Thermostat item for its current temperature item
|
|
145
|
-
# eFamilyThermostat.points(Semantics::Status, Semantics::Temperature)
|
|
146
|
-
# # => [FamilyThermostat_AmbTemp]
|
|
147
|
-
# @example Search a Thermostat item for is setpoints
|
|
148
|
-
# eFamilyThermostat.points(Semantics::Control, Semantics::Temperature)
|
|
149
|
-
# # => [FamilyThermostat_HeatingSetpoint, FamilyThermostat_CoolingSetpoint]
|
|
150
|
-
# @example Given a A/V receiver's input item, search for its power item
|
|
151
|
-
# FamilyReceiver_Input.points(Semantics::Switch) # => [FamilyReceiver_Switch]
|
|
152
|
-
#
|
|
153
|
-
# @param [Class] point_or_property_types
|
|
154
|
-
# Pass 1 or 2 classes that are sub-classes of [Point] or [Property].
|
|
155
|
-
# Note that when comparing against semantic tags, it does a sub-class check.
|
|
156
|
-
# So if you search for [Control], you'll get items tagged with [Switch].
|
|
157
|
-
# @return [Array<GenericItem>]
|
|
158
|
-
def points(*point_or_property_types)
|
|
159
|
-
return members.points(*point_or_property_types) if equipment? || location?
|
|
160
|
-
|
|
161
|
-
# automatically search the parent equipment (or location?!) for sibling points
|
|
162
|
-
result = (equipment || location)&.points(*point_or_property_types) || []
|
|
163
|
-
# remove self. but avoid state comparisons
|
|
164
|
-
result.delete_if { |item| item.eql?(self) }
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
# Additions to Enumerable to allow easily filtering groups of items based on the semantic model
|
|
172
|
-
module Enumerable
|
|
173
|
-
# Returns a new array of items that are a semantics Location (optionally of the given type)
|
|
174
|
-
def locations(type = nil)
|
|
175
|
-
if type && !(type < OpenHAB::DSL::Items::Semantics::Location)
|
|
176
|
-
raise ArgumentError, 'type must be a subclass of Location'
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
result = select(&:location?)
|
|
180
|
-
result.select! { |i| i.location_type <= type } if type
|
|
181
|
-
|
|
182
|
-
result
|
|
183
|
-
end
|
|
184
|
-
# @deprecated Please use {#locations}
|
|
185
|
-
alias sublocations locations
|
|
186
|
-
|
|
187
|
-
# Returns a new array of items that are a semantics equipment (optionally of the given type)
|
|
188
|
-
#
|
|
189
|
-
# @example Get all TVs in a room
|
|
190
|
-
# lGreatRoom.equipments(Semantics::Screen)
|
|
191
|
-
def equipments(type = nil)
|
|
192
|
-
if type && !(type < OpenHAB::DSL::Items::Semantics::Equipment)
|
|
193
|
-
raise ArgumentError, 'type must be a subclass of Equipment'
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
result = select(&:equipment?)
|
|
197
|
-
result.select! { |i| i.equipment_type <= type } if type
|
|
198
|
-
|
|
199
|
-
result
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
# Returns a new array of items that are semantics points (optionally of a given type)
|
|
203
|
-
#
|
|
204
|
-
# @example Get all the power switch items for every equipment in a room
|
|
205
|
-
# lGreatRoom.equipments.points(Semantics::Switch)
|
|
206
|
-
def points(*point_or_property_types) # rubocop:disable Metrics
|
|
207
|
-
unless (0..2).cover?(point_or_property_types.length)
|
|
208
|
-
raise ArgumentError, "wrong number of arguments (given #{point_or_property_types.length}, expected 0..2)"
|
|
209
|
-
end
|
|
210
|
-
unless point_or_property_types.all? do |tag|
|
|
211
|
-
tag < OpenHAB::DSL::Items::Semantics::Point || tag < OpenHAB::DSL::Items::Semantics::Property
|
|
212
|
-
end
|
|
213
|
-
raise ArgumentError, 'point_or_property_types must all be a subclass of Point or Property'
|
|
214
|
-
end
|
|
215
|
-
if point_or_property_types.count { |tag| tag < OpenHAB::DSL::Items::Semantics::Point } > 1 ||
|
|
216
|
-
point_or_property_types.count { |tag| tag < OpenHAB::DSL::Items::Semantics::Property } > 1
|
|
217
|
-
raise ArgumentError, 'point_or_property_types cannot both be a subclass of Point or Property'
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
select do |point|
|
|
221
|
-
point.point? && point_or_property_types.all? do |tag|
|
|
222
|
-
(tag < OpenHAB::DSL::Items::Semantics::Point && point.point_type <= tag) ||
|
|
223
|
-
(tag < OpenHAB::DSL::Items::Semantics::Property && point.property_type&.<=(tag))
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'forwardable'
|
|
4
|
-
|
|
5
|
-
require 'openhab/dsl/items/comparable_item'
|
|
6
|
-
|
|
7
|
-
module OpenHAB
|
|
8
|
-
module DSL
|
|
9
|
-
module Items
|
|
10
|
-
java_import org.openhab.core.library.items.StringItem
|
|
11
|
-
|
|
12
|
-
# Adds methods to core OpenHAB StringItem type to make it more natural in
|
|
13
|
-
# Ruby
|
|
14
|
-
class StringItem < GenericItem
|
|
15
|
-
extend Forwardable
|
|
16
|
-
include Comparable
|
|
17
|
-
include ComparableItem
|
|
18
|
-
|
|
19
|
-
remove_method :==
|
|
20
|
-
|
|
21
|
-
# @return [Regex] Regular expression matching blank strings
|
|
22
|
-
BLANK_RE = /\A[[:space:]]*\z/.freeze
|
|
23
|
-
private_constant :BLANK_RE
|
|
24
|
-
|
|
25
|
-
#
|
|
26
|
-
# Detect if the string is blank (not set or only whitespace)
|
|
27
|
-
#
|
|
28
|
-
# @return [Boolean] True if string item is not set or contains only whitespace, false otherwise
|
|
29
|
-
#
|
|
30
|
-
def blank?
|
|
31
|
-
return true unless state?
|
|
32
|
-
|
|
33
|
-
state.empty? || BLANK_RE.match?(self)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
#
|
|
37
|
-
# Check if StringItem is truthy? as per defined by library
|
|
38
|
-
#
|
|
39
|
-
# @return [Boolean] True if item is not in state UNDEF or NULL and value is not blank
|
|
40
|
-
#
|
|
41
|
-
def truthy?
|
|
42
|
-
state? && !blank?
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# any method that exists on String gets forwarded to state (which will forward as
|
|
46
|
-
# necessary)
|
|
47
|
-
delegate (String.instance_methods - instance_methods) => :state
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module OpenHAB
|
|
4
|
-
module DSL
|
|
5
|
-
#
|
|
6
|
-
# Patches OpenHAB items
|
|
7
|
-
#
|
|
8
|
-
module Items
|
|
9
|
-
java_import org.openhab.core.library.items.SwitchItem
|
|
10
|
-
|
|
11
|
-
# Alias class names for easy is_a? comparisons
|
|
12
|
-
::Switch = SwitchItem
|
|
13
|
-
|
|
14
|
-
# Adds methods to core OpenHAB SwitchItem type to make it more natural in
|
|
15
|
-
# Ruby
|
|
16
|
-
class SwitchItem < GenericItem
|
|
17
|
-
remove_method :==
|
|
18
|
-
|
|
19
|
-
def truthy?
|
|
20
|
-
on?
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Convert boolean commands to ON/OFF
|
|
24
|
-
# @!visibility private
|
|
25
|
-
def format_type(command)
|
|
26
|
-
return Types::OnOffType.from(command) if [true, false].include?(command)
|
|
27
|
-
|
|
28
|
-
super
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
#
|
|
32
|
-
# Send a command to invert the state of the switch
|
|
33
|
-
#
|
|
34
|
-
# @return [Types::OnOffType] Inverted state
|
|
35
|
-
#
|
|
36
|
-
def toggle
|
|
37
|
-
command(!self)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
#
|
|
41
|
-
# Return the inverted state of the switch: +ON+ if the switch is +OFF+,
|
|
42
|
-
# +UNDEF+ or +NULL+; +OFF+ if the switch is +ON+
|
|
43
|
-
#
|
|
44
|
-
# @return [Types::OnOffType] Inverted state
|
|
45
|
-
#
|
|
46
|
-
def !
|
|
47
|
-
return !state if state?
|
|
48
|
-
|
|
49
|
-
ON
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# @!method on?
|
|
53
|
-
# Check if the item state == +ON+
|
|
54
|
-
# @return [Boolean]
|
|
55
|
-
|
|
56
|
-
# @!method off?
|
|
57
|
-
# Check if the item state == +OFF+
|
|
58
|
-
# @return [Boolean]
|
|
59
|
-
|
|
60
|
-
# @!method on
|
|
61
|
-
# Send the +ON+ command to the item
|
|
62
|
-
# @return [SwitchItem] +self+
|
|
63
|
-
|
|
64
|
-
# @!method off
|
|
65
|
-
# Send the +OFF+ command to the item
|
|
66
|
-
# @return [SwitchItem] +self+
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'java'
|
|
4
|
-
|
|
5
|
-
module OpenHAB
|
|
6
|
-
module DSL
|
|
7
|
-
module MonkeyPatch
|
|
8
|
-
#
|
|
9
|
-
# Patches OpenHAB actions
|
|
10
|
-
#
|
|
11
|
-
module Actions
|
|
12
|
-
begin
|
|
13
|
-
# openHAB 3.3 uses ScriptThingActionsImpl
|
|
14
|
-
java_import Java::OrgOpenhabCoreAutomationModuleScriptInternalDefaultscope::ScriptThingActionsImpl
|
|
15
|
-
rescue NameError
|
|
16
|
-
# openHAB 3.2 uses ScriptThingActions
|
|
17
|
-
java_import Java::OrgOpenhabCoreAutomationModuleScriptInternalDefaultscope::ScriptThingActions
|
|
18
|
-
ScriptThingActionsImpl = ScriptThingActions
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
#
|
|
22
|
-
# MonkeyPatching ScriptThingActions
|
|
23
|
-
#
|
|
24
|
-
class ScriptThingActionsImpl
|
|
25
|
-
field_reader :THING_ACTIONS_MAP
|
|
26
|
-
|
|
27
|
-
#
|
|
28
|
-
# Fetch keys for all actions defined in OpenHAB
|
|
29
|
-
#
|
|
30
|
-
# @return [Set] of keys for defined actions in the form of 'scope-thing_uid'
|
|
31
|
-
#
|
|
32
|
-
def action_keys
|
|
33
|
-
self.class.THING_ACTIONS_MAP.keys
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'openhab/dsl/monkey_patch/events/item_event'
|
|
4
|
-
require 'openhab/dsl/monkey_patch/events/item_state'
|
|
5
|
-
require 'openhab/dsl/monkey_patch/events/item_state_changed'
|
|
6
|
-
require 'openhab/dsl/monkey_patch/events/item_command'
|
|
7
|
-
require 'openhab/dsl/monkey_patch/events/thing_status_info'
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'item_event'
|
|
4
|
-
|
|
5
|
-
module OpenHAB
|
|
6
|
-
module DSL
|
|
7
|
-
module MonkeyPatch
|
|
8
|
-
#
|
|
9
|
-
# Patches OpenHAB events
|
|
10
|
-
#
|
|
11
|
-
module Events
|
|
12
|
-
java_import org.openhab.core.items.events.ItemCommandEvent
|
|
13
|
-
|
|
14
|
-
# Adds methods to core OpenHAB ItemCommandEvent to make it more natural in Ruby
|
|
15
|
-
class ItemCommandEvent < ItemEvent
|
|
16
|
-
# @return [Type]
|
|
17
|
-
alias command item_command
|
|
18
|
-
|
|
19
|
-
# @!method refresh?
|
|
20
|
-
# Check if == +REFRESH+
|
|
21
|
-
# @return [Boolean]
|
|
22
|
-
|
|
23
|
-
# @!method on?
|
|
24
|
-
# Check if == +ON+
|
|
25
|
-
# @return [Boolean]
|
|
26
|
-
|
|
27
|
-
# @!method off?
|
|
28
|
-
# Check if == +OFF+
|
|
29
|
-
# @return [Boolean]
|
|
30
|
-
|
|
31
|
-
# @!method up?
|
|
32
|
-
# Check if == +UP+
|
|
33
|
-
# @return [Boolean]
|
|
34
|
-
|
|
35
|
-
# @!method down?
|
|
36
|
-
# Check if == +DOWN+
|
|
37
|
-
# @return [Boolean]
|
|
38
|
-
|
|
39
|
-
# @!method stop?
|
|
40
|
-
# Check if == +STOP+
|
|
41
|
-
# @return [Boolean]
|
|
42
|
-
|
|
43
|
-
# @!method move?
|
|
44
|
-
# Check if == +MOVE+
|
|
45
|
-
# @return [Boolean]
|
|
46
|
-
|
|
47
|
-
# @!method increase?
|
|
48
|
-
# Check if == +INCREASE+
|
|
49
|
-
# @return [Boolean]
|
|
50
|
-
|
|
51
|
-
# @!method decrease?
|
|
52
|
-
# Check if == +DECREASE+
|
|
53
|
-
# @return [Boolean]
|
|
54
|
-
|
|
55
|
-
# @!method play?
|
|
56
|
-
# Check if == +PLAY+
|
|
57
|
-
# @return [Boolean]
|
|
58
|
-
|
|
59
|
-
# @!method pause?
|
|
60
|
-
# Check if == +PAUSE+
|
|
61
|
-
# @return [Boolean]
|
|
62
|
-
|
|
63
|
-
# @!method rewind?
|
|
64
|
-
# Check if == +REWIND+
|
|
65
|
-
# @return [Boolean]
|
|
66
|
-
|
|
67
|
-
# @!method fast_forward?
|
|
68
|
-
# Check if == +FASTFORWARD+
|
|
69
|
-
# @return [Boolean]
|
|
70
|
-
|
|
71
|
-
# @deprecated
|
|
72
|
-
# @!parse alias fastforward? fast_forward?
|
|
73
|
-
|
|
74
|
-
# @!method next?
|
|
75
|
-
# Check if == +NEXT+
|
|
76
|
-
# @return [Boolean]
|
|
77
|
-
|
|
78
|
-
# @!method previous?
|
|
79
|
-
# Check if == +PREVIOUS+
|
|
80
|
-
# @return [Boolean]
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module OpenHAB
|
|
4
|
-
module DSL
|
|
5
|
-
module MonkeyPatch
|
|
6
|
-
#
|
|
7
|
-
# Patches OpenHAB events
|
|
8
|
-
#
|
|
9
|
-
module Events
|
|
10
|
-
java_import org.openhab.core.items.events.ItemEvent
|
|
11
|
-
|
|
12
|
-
#
|
|
13
|
-
# Adds methods to core OpenHAB ItemEvent to make it more natural in Ruby
|
|
14
|
-
#
|
|
15
|
-
class ItemEvent
|
|
16
|
-
#
|
|
17
|
-
# The triggering item
|
|
18
|
-
#
|
|
19
|
-
# @return [GenericItem]
|
|
20
|
-
#
|
|
21
|
-
def item
|
|
22
|
-
OpenHAB::Core::EntityLookup.lookup_item(item_name)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'openhab/dsl/types/un_def_type'
|
|
4
|
-
|
|
5
|
-
module OpenHAB
|
|
6
|
-
module DSL
|
|
7
|
-
module MonkeyPatch
|
|
8
|
-
#
|
|
9
|
-
# Patches OpenHAB events
|
|
10
|
-
#
|
|
11
|
-
module Events
|
|
12
|
-
java_import org.openhab.core.items.events.ItemStateEvent
|
|
13
|
-
|
|
14
|
-
# Helpers common to ItemStateEvent and ItemStateChangedEvent
|
|
15
|
-
module ItemState
|
|
16
|
-
#
|
|
17
|
-
# Check if the state == UNDEF
|
|
18
|
-
#
|
|
19
|
-
# @return [Boolean] True if the state is UNDEF, false otherwise
|
|
20
|
-
#
|
|
21
|
-
def undef?
|
|
22
|
-
item_state == UNDEF
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
#
|
|
26
|
-
# Check if the state == NULL
|
|
27
|
-
#
|
|
28
|
-
# @return [Boolean] True if the state is NULL, false otherwise
|
|
29
|
-
def null?
|
|
30
|
-
item_state == NULL
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
#
|
|
34
|
-
# Check if the state is defined (not UNDEF or NULL)
|
|
35
|
-
#
|
|
36
|
-
# @return [Boolean] True if state is not UNDEF or NULL
|
|
37
|
-
#
|
|
38
|
-
def state?
|
|
39
|
-
!item_state.is_a?(Types::UnDefType)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
#
|
|
43
|
-
# Get the item state
|
|
44
|
-
#
|
|
45
|
-
# @return [Types::PrimitiveState] OpenHAB state if state is not UNDEF or NULL, nil otherwise
|
|
46
|
-
#
|
|
47
|
-
def state
|
|
48
|
-
item_state if state?
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
#
|
|
53
|
-
# Adds methods to core OpenHAB ItemStateEvent to make it more natural in Ruby
|
|
54
|
-
#
|
|
55
|
-
class ItemStateEvent < ItemEvent
|
|
56
|
-
include ItemState
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'openhab/dsl/types/un_def_type'
|
|
4
|
-
|
|
5
|
-
module OpenHAB
|
|
6
|
-
module DSL
|
|
7
|
-
module MonkeyPatch
|
|
8
|
-
#
|
|
9
|
-
# Patches OpenHAB events
|
|
10
|
-
#
|
|
11
|
-
module Events
|
|
12
|
-
java_import org.openhab.core.items.events.ItemStateChangedEvent
|
|
13
|
-
|
|
14
|
-
#
|
|
15
|
-
# Adds methods to core OpenHAB ItemStateChangedEvent to make it more natural in Ruby
|
|
16
|
-
#
|
|
17
|
-
class ItemStateChangedEvent < ItemEvent
|
|
18
|
-
include ItemState
|
|
19
|
-
|
|
20
|
-
#
|
|
21
|
-
# Check if state was == UNDEF
|
|
22
|
-
#
|
|
23
|
-
# @return [Boolean] True if the state is UNDEF, false otherwise
|
|
24
|
-
#
|
|
25
|
-
def was_undef?
|
|
26
|
-
old_item_state == UNDEF
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
#
|
|
30
|
-
# Check if state was == NULL
|
|
31
|
-
#
|
|
32
|
-
# @return [Boolean] True if the state is NULL, false otherwise
|
|
33
|
-
def was_null?
|
|
34
|
-
old_item_state == NULL
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
# Check if state was defined (not UNDEF or NULL)
|
|
39
|
-
#
|
|
40
|
-
# @return [Boolean] True if state is not UNDEF or NULL
|
|
41
|
-
#
|
|
42
|
-
def was?
|
|
43
|
-
!old_item_state.is_a?(Types::UnDefType)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
#
|
|
47
|
-
# Get the previous item state
|
|
48
|
-
#
|
|
49
|
-
# @return [Types::Type] OpenHAB state if state was not UNDEF or NULL, nil otherwise
|
|
50
|
-
#
|
|
51
|
-
def was
|
|
52
|
-
old_item_state if was?
|
|
53
|
-
end
|
|
54
|
-
# @deprecated
|
|
55
|
-
alias last was
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'java'
|
|
4
|
-
|
|
5
|
-
module OpenHAB
|
|
6
|
-
module DSL
|
|
7
|
-
module MonkeyPatch
|
|
8
|
-
#
|
|
9
|
-
# Patches OpenHAB events
|
|
10
|
-
#
|
|
11
|
-
module Event
|
|
12
|
-
java_import org.openhab.core.thing.events.ThingStatusInfoChangedEvent
|
|
13
|
-
java_import org.openhab.core.thing.events.ThingStatusInfoEvent
|
|
14
|
-
#
|
|
15
|
-
# Monkey patch with ruby style accessors
|
|
16
|
-
#
|
|
17
|
-
class ThingStatusInfoChangedEvent
|
|
18
|
-
alias uid get_thing_uid
|
|
19
|
-
alias last get_old_status_info
|
|
20
|
-
alias status status_info
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
#
|
|
24
|
-
# Monkey patch with ruby style accessors
|
|
25
|
-
#
|
|
26
|
-
class ThingStatusInfoEvent
|
|
27
|
-
alias uid get_thing_uid
|
|
28
|
-
alias status status_info
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|