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,307 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module OpenHAB
|
|
4
|
-
module DSL
|
|
5
|
-
module Items
|
|
6
|
-
#
|
|
7
|
-
# Persistence extension for Items
|
|
8
|
-
#
|
|
9
|
-
# @note Methods that accept a timestamp can accept a ++ZonedDateTime++, Ruby ++Time++, or a ++Duration++.
|
|
10
|
-
# When given a positive Duration, the timestamp will be calculated as ++now-Duration++
|
|
11
|
-
#
|
|
12
|
-
module Persistence
|
|
13
|
-
java_import org.openhab.core.types.util.UnitUtils
|
|
14
|
-
|
|
15
|
-
# A state class with an added timestamp attribute. This is used to hold OpenHAB's HistoricItem.
|
|
16
|
-
class HistoricState < SimpleDelegator
|
|
17
|
-
attr_reader :timestamp, :state
|
|
18
|
-
|
|
19
|
-
def initialize(state, timestamp)
|
|
20
|
-
@state = state
|
|
21
|
-
@timestamp = timestamp
|
|
22
|
-
super(@state)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# All persistence methods that could return a QuantityType
|
|
27
|
-
QUANTITY_METHODS = %i[average_since
|
|
28
|
-
delta_since
|
|
29
|
-
deviation_since
|
|
30
|
-
sum_since
|
|
31
|
-
variance_since].freeze
|
|
32
|
-
|
|
33
|
-
# All persistence methods that require a timestamp
|
|
34
|
-
PERSISTENCE_METHODS = (QUANTITY_METHODS +
|
|
35
|
-
%i[changed_since?
|
|
36
|
-
evolution_rate
|
|
37
|
-
historic_state
|
|
38
|
-
maximum_since
|
|
39
|
-
minimum_since
|
|
40
|
-
updated_since?]).freeze
|
|
41
|
-
private_constant :QUANTITY_METHODS, :PERSISTENCE_METHODS
|
|
42
|
-
|
|
43
|
-
# @!method persist(service = nil)
|
|
44
|
-
# Persist the state of the item
|
|
45
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
46
|
-
# @return [void]
|
|
47
|
-
|
|
48
|
-
# @!method last_update(service = nil)
|
|
49
|
-
# Return the time the item was last updated.
|
|
50
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
51
|
-
# @return [ZonedDateTime] The timestamp of the last update
|
|
52
|
-
|
|
53
|
-
# @!method average_since(timestamp, service = nil)
|
|
54
|
-
# Return the average value of the item's state since the given time
|
|
55
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time from which to search
|
|
56
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
57
|
-
# @return [DecimalType, QuantityType, nil] The average value since ++timestamp++,
|
|
58
|
-
# or nil if no previous state could be found.
|
|
59
|
-
|
|
60
|
-
# @!method average_between(start, finish, service = nil)
|
|
61
|
-
# Return the average value of the item's state between two points in time
|
|
62
|
-
# @param [ZonedDateTime, Time, Duration] start The point in time from which to search
|
|
63
|
-
# @param [ZonedDateTime, Time, Duration] finish The point in time to which to search
|
|
64
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
65
|
-
# @return [DecimalType, QuantityType, nil] The average value between ++start++ and ++finish++,
|
|
66
|
-
# or nil if no previous state could be found.
|
|
67
|
-
|
|
68
|
-
# @!method delta_since(timestamp, service = nil)
|
|
69
|
-
# Return the difference value of the item's state since the given time
|
|
70
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time from which to search
|
|
71
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
72
|
-
# @return [DecimalType, QuantityType, nil] The difference value since ++timestamp++,
|
|
73
|
-
# or nil if no previous state could be found.
|
|
74
|
-
|
|
75
|
-
# @!method delta_between(start, finish, service = nil)
|
|
76
|
-
# Return the difference value of the item's state between two points in time
|
|
77
|
-
# @param [ZonedDateTime, Time, Duration] start The point in time from which to search
|
|
78
|
-
# @param [ZonedDateTime, Time, Duration] finish The point in time to which to search
|
|
79
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
80
|
-
# @return [DecimalType, QuantityType, nil] The difference value between ++start++ and ++finish++,
|
|
81
|
-
# or nil if no previous state could be found.
|
|
82
|
-
|
|
83
|
-
# @!method deviation_since(timestamp, service = nil)
|
|
84
|
-
# Return the standard deviation of the item's state since the given time
|
|
85
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time from which to search
|
|
86
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
87
|
-
# @return [DecimalType, QuantityType, nil] The standard deviation since ++timestamp++,
|
|
88
|
-
# or nil if no previous state could be found.
|
|
89
|
-
|
|
90
|
-
# @!method deviation_between(start, finish, service = nil)
|
|
91
|
-
# Return the standard deviation of the item's state between two points in time
|
|
92
|
-
# @param [ZonedDateTime, Time, Duration] start The point in time from which to search
|
|
93
|
-
# @param [ZonedDateTime, Time, Duration] finish The point in time to which to search
|
|
94
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
95
|
-
# @return [DecimalType, QuantityType, nil] The standard deviation between ++start++ and ++finish++,
|
|
96
|
-
# or nil if no previous state could be found.
|
|
97
|
-
|
|
98
|
-
# @!method sum_since(timestamp, service = nil)
|
|
99
|
-
# Return the sum of the item's state since the given time
|
|
100
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time from which to search
|
|
101
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
102
|
-
# @return [DecimalType, QuantityType, nil] The sum since ++timestamp++,
|
|
103
|
-
# or nil if no previous state could be found.
|
|
104
|
-
|
|
105
|
-
# @!method sum_between(start, finish, service = nil)
|
|
106
|
-
# Return the sum of the item's state between two points in time
|
|
107
|
-
# @param [ZonedDateTime, Time, Duration] start The point in time from which to search
|
|
108
|
-
# @param [ZonedDateTime, Time, Duration] finish The point in time to which to search
|
|
109
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
110
|
-
# @return [DecimalType, QuantityType, nil] The sum between ++start++ and ++finish++,
|
|
111
|
-
# or nil if no previous state could be found.
|
|
112
|
-
|
|
113
|
-
# @!method variance_since(timestamp, service = nil)
|
|
114
|
-
# Return the variance of the item's state since the given time
|
|
115
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time from which to search
|
|
116
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
117
|
-
# @return [DecimalType, QuantityType, nil] The variance since ++timestamp++,
|
|
118
|
-
# or nil if no previous state could be found.
|
|
119
|
-
|
|
120
|
-
# @!method variance_between(start, finish, service = nil)
|
|
121
|
-
# Return the variance of the item's state between two points in time
|
|
122
|
-
# @param [ZonedDateTime, Time, Duration] start The point in time from which to search
|
|
123
|
-
# @param [ZonedDateTime, Time, Duration] finish The point in time to which to search
|
|
124
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
125
|
-
# @return [DecimalType, QuantityType, nil] The variance between ++start++ and ++finish++,
|
|
126
|
-
# or nil if no previous state could be found.
|
|
127
|
-
|
|
128
|
-
# @!method changed_since?(timestamp, service = nil)
|
|
129
|
-
# Whether the item's state has changed since the given time
|
|
130
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time from which to search
|
|
131
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
132
|
-
# @return [Boolean] True if the item's state has changed since the given ++timestamp++, False otherwise.
|
|
133
|
-
|
|
134
|
-
# @!method changed_between?(start, finish, service = nil)
|
|
135
|
-
# Whether the item's state changed between two points in time
|
|
136
|
-
# @param [ZonedDateTime, Time, Duration] start The point in time from which to search
|
|
137
|
-
# @param [ZonedDateTime, Time, Duration] finish The point in time to which to search
|
|
138
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
139
|
-
# @return [Boolean] True if the item's state changed between ++start++ and ++finish++, False otherwise.
|
|
140
|
-
|
|
141
|
-
# @!method evolution_rate(timestamp, service = nil)
|
|
142
|
-
# Return the evolution rate of the item's state since the given time
|
|
143
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time from which to search
|
|
144
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
145
|
-
# @return [DecimalType, QuantityType, nil] The evolution rate since ++timestamp++,
|
|
146
|
-
# or nil if no previous state could be found.
|
|
147
|
-
|
|
148
|
-
# @!method historic_state(timestamp, service = nil)
|
|
149
|
-
# Return the the item's state at the given time
|
|
150
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time at which to search
|
|
151
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
152
|
-
# @return [HistoricState, nil] The item's state at ++timestamp++,
|
|
153
|
-
# or nil if no previous state could be found.
|
|
154
|
-
|
|
155
|
-
# @!method maximum_since(timestamp, service = nil)
|
|
156
|
-
# Return the maximum value of the item's state since the given time
|
|
157
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time from which to search
|
|
158
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
159
|
-
# @return [HistoricState, nil] The maximum value since ++timestamp++,
|
|
160
|
-
# or nil if no previous state could be found.
|
|
161
|
-
|
|
162
|
-
# @!method maximum_between(start, finish, service = nil)
|
|
163
|
-
# Return the maximum value of the item's state between two points in time
|
|
164
|
-
# @param [ZonedDateTime, Time, Duration] start The point in time from which to search
|
|
165
|
-
# @param [ZonedDateTime, Time, Duration] finish The point in time to which to search
|
|
166
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
167
|
-
# @return [HistoricState, nil] The maximum value between ++start++ and ++finish++,
|
|
168
|
-
# or nil if no previous state could be found.
|
|
169
|
-
|
|
170
|
-
# @!method minimum_since(timestamp, service = nil)
|
|
171
|
-
# Return the minimum value of the item's state since the given time
|
|
172
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time from which to search
|
|
173
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
174
|
-
# @return [HistoricState, nil] The minimum value since ++timestamp++,
|
|
175
|
-
# or nil if no previous state could be found.
|
|
176
|
-
|
|
177
|
-
# @!method minimum_between(start, finish, service = nil)
|
|
178
|
-
# Return the minimum value of the item's state between two points in time
|
|
179
|
-
# @param [ZonedDateTime, Time, Duration] start The point in time from which to search
|
|
180
|
-
# @param [ZonedDateTime, Time, Duration] finish The point in time to which to search
|
|
181
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
182
|
-
# @return [HistoricState, nil] The minimum value between ++start++ and ++finish++,
|
|
183
|
-
# or nil if no previous state could be found.
|
|
184
|
-
|
|
185
|
-
# @!method updated_since?(timestamp, service = nil)
|
|
186
|
-
# Whether the item's state has been updated since the given time
|
|
187
|
-
# @param [ZonedDateTime, Time, Duration] timestamp The point in time from which to search
|
|
188
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
189
|
-
# @return [Boolean] True if the item's state has been updated since the given ++timestamp++, False otherwise.
|
|
190
|
-
|
|
191
|
-
# @!method updated_between?(start, finish, service = nil)
|
|
192
|
-
# Whether the item's state was updated between two points in time
|
|
193
|
-
# @param [ZonedDateTime, Time, Duration] start The point in time from which to search
|
|
194
|
-
# @param [ZonedDateTime, Time, Duration] finish The point in time to which to search
|
|
195
|
-
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
196
|
-
# @return [Boolean] True if the item's state was updated between ++start++ and ++finish++, False otherwise.
|
|
197
|
-
|
|
198
|
-
%i[persist last_update].each do |method|
|
|
199
|
-
define_method(method) do |service = nil|
|
|
200
|
-
service ||= persistence_service
|
|
201
|
-
PersistenceExtensions.public_send(method, self, service&.to_s)
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
#
|
|
206
|
-
# Return the previous state of the item
|
|
207
|
-
#
|
|
208
|
-
# @param skip_equal [Boolean] if true, skips equal state values and
|
|
209
|
-
# searches the first state not equal the current state
|
|
210
|
-
# @param service [String] the name of the PersistenceService to use
|
|
211
|
-
#
|
|
212
|
-
# @return [HistoricState, nil] the previous state or nil if no previous state could be found,
|
|
213
|
-
# or if the default persistence service is not configured or
|
|
214
|
-
# does not refer to a valid service
|
|
215
|
-
#
|
|
216
|
-
def previous_state(service = nil, skip_equal: false)
|
|
217
|
-
service ||= persistence_service
|
|
218
|
-
result = PersistenceExtensions.previous_state(self, skip_equal, service&.to_s)
|
|
219
|
-
HistoricState.new(quantify(result.state), result.timestamp)
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
PERSISTENCE_METHODS.each do |method|
|
|
223
|
-
define_method(method) do |timestamp, service = nil|
|
|
224
|
-
service ||= persistence_service
|
|
225
|
-
result = PersistenceExtensions.public_send(method.to_s.delete_suffix('?'), self, to_zdt(timestamp),
|
|
226
|
-
service&.to_s)
|
|
227
|
-
wrap_result(result, method)
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
next unless /_since\??$/.match?(method.to_s)
|
|
231
|
-
|
|
232
|
-
between_method = method.to_s.sub('_since', '_between').to_sym
|
|
233
|
-
define_method(between_method) do |start, finish, service = nil|
|
|
234
|
-
service ||= persistence_service
|
|
235
|
-
result = PersistenceExtensions.public_send(between_method.to_s.delete_suffix('?'), self, to_zdt(start),
|
|
236
|
-
to_zdt(finish), service&.to_s)
|
|
237
|
-
wrap_result(result, method)
|
|
238
|
-
end
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
alias changed_since changed_since?
|
|
242
|
-
alias changed_between changed_between?
|
|
243
|
-
alias updated_since updated_since?
|
|
244
|
-
alias updated_between updated_between?
|
|
245
|
-
|
|
246
|
-
private
|
|
247
|
-
|
|
248
|
-
#
|
|
249
|
-
# Convert timestamp to ZonedDateTime with duration negated to indicate a time in the past
|
|
250
|
-
#
|
|
251
|
-
# @param [Object] timestamp timestamp to convert
|
|
252
|
-
#
|
|
253
|
-
# @return [ZonedDateTime]
|
|
254
|
-
#
|
|
255
|
-
def to_zdt(timestamp)
|
|
256
|
-
timestamp = timestamp.negated if timestamp.is_a? java.time.Duration
|
|
257
|
-
OpenHAB::DSL.to_zdt(timestamp)
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
#
|
|
261
|
-
# Convert value to QuantityType if it is a DecimalType and a unit is defined
|
|
262
|
-
#
|
|
263
|
-
# @param [Object] value The value to convert
|
|
264
|
-
#
|
|
265
|
-
# @return [Object] QuantityType or the original value
|
|
266
|
-
#
|
|
267
|
-
def quantify(value)
|
|
268
|
-
if value.is_a?(Types::DecimalType) && (item_unit = UnitUtils.parse_unit(state_description&.pattern))
|
|
269
|
-
logger.trace("Unitizing #{value} with unit #{item_unit}")
|
|
270
|
-
Types::QuantityType.new(value.to_big_decimal, item_unit)
|
|
271
|
-
else
|
|
272
|
-
value
|
|
273
|
-
end
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
#
|
|
277
|
-
# Wrap the result into a more convenient object type depending on the method and result.
|
|
278
|
-
#
|
|
279
|
-
# @param [Object] result the raw result type to be wrapped
|
|
280
|
-
# @param [Symbol] method the name of the called method
|
|
281
|
-
#
|
|
282
|
-
# @return [HistoricState] a {HistoricState} object if the result was a HistoricItem
|
|
283
|
-
# @return [QuantityType] a ++QuantityType++ object if the result was an average, delta, deviation,
|
|
284
|
-
# sum, or variance.
|
|
285
|
-
# @return [Object] the original result object otherwise.
|
|
286
|
-
#
|
|
287
|
-
def wrap_result(result, method)
|
|
288
|
-
java_import org.openhab.core.persistence.HistoricItem
|
|
289
|
-
|
|
290
|
-
return HistoricState.new(quantify(result.state), result.timestamp) if result.is_a?(HistoricItem)
|
|
291
|
-
return quantify(result) if QUANTITY_METHODS.include?(method)
|
|
292
|
-
|
|
293
|
-
result
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
#
|
|
297
|
-
# Get the specified persistence service from the current thread local variable
|
|
298
|
-
#
|
|
299
|
-
# @return [Object] Persistence service name as String or Symbol, or nil if not set
|
|
300
|
-
#
|
|
301
|
-
def persistence_service
|
|
302
|
-
Thread.current.thread_variable_get(:persistence_service)
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
end
|
|
306
|
-
end
|
|
307
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module OpenHAB
|
|
4
|
-
module DSL
|
|
5
|
-
module Items
|
|
6
|
-
java_import org.openhab.core.library.items.PlayerItem
|
|
7
|
-
|
|
8
|
-
# Adds methods to core OpenHAB NumberItem type to make it more natural in
|
|
9
|
-
# Ruby
|
|
10
|
-
class PlayerItem < GenericItem
|
|
11
|
-
remove_method :==
|
|
12
|
-
|
|
13
|
-
# @!method play?
|
|
14
|
-
# Check if the item state == +PLAYING+
|
|
15
|
-
# @return [Boolean]
|
|
16
|
-
|
|
17
|
-
# @deprecated
|
|
18
|
-
# @!parse alias play? playing?
|
|
19
|
-
|
|
20
|
-
# @!method paused?
|
|
21
|
-
# Check if the item state == +PAUSED+
|
|
22
|
-
# @return [Boolean]
|
|
23
|
-
|
|
24
|
-
# @!method rewinding?
|
|
25
|
-
# Check if the item state == +REWIND+
|
|
26
|
-
# @return [Boolean]
|
|
27
|
-
|
|
28
|
-
# @!method fast_forwarding?
|
|
29
|
-
# Check if the item state == +FASTFORWARD+
|
|
30
|
-
# @return [Boolean]
|
|
31
|
-
|
|
32
|
-
# @!method play
|
|
33
|
-
# Send the +PLAY+ command to the item
|
|
34
|
-
# @return [PlayerItem] +self+
|
|
35
|
-
|
|
36
|
-
# @!method pause
|
|
37
|
-
# Send the +PAUSE+ command to the item
|
|
38
|
-
# @return [PlayerItem] +self+
|
|
39
|
-
|
|
40
|
-
# @!method rewind
|
|
41
|
-
# Send the +REWIND+ command to the item
|
|
42
|
-
# @return [PlayerItem] +self+
|
|
43
|
-
|
|
44
|
-
# @!method fast_forward
|
|
45
|
-
# Send the +FASTFORWARD+ command to the item
|
|
46
|
-
# @return [PlayerItem] +self+
|
|
47
|
-
|
|
48
|
-
# @!method next
|
|
49
|
-
# Send the +NEXT+ command to the item
|
|
50
|
-
# @return [PlayerItem] +self+
|
|
51
|
-
|
|
52
|
-
# @!method previous
|
|
53
|
-
# Send the +PREVIOUS+ command to the item
|
|
54
|
-
# @return [PlayerItem] +self+
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'numeric_item'
|
|
4
|
-
|
|
5
|
-
module OpenHAB
|
|
6
|
-
module DSL
|
|
7
|
-
module Items
|
|
8
|
-
java_import org.openhab.core.library.items.RollershutterItem
|
|
9
|
-
|
|
10
|
-
# Adds methods to core OpenHAB RollershutterItem type to make it more natural in
|
|
11
|
-
# Ruby
|
|
12
|
-
class RollershutterItem < GenericItem
|
|
13
|
-
include NumericItem
|
|
14
|
-
|
|
15
|
-
alias position state
|
|
16
|
-
|
|
17
|
-
# @!method up?
|
|
18
|
-
# Check if the item state == +UP+
|
|
19
|
-
# @return [Boolean]
|
|
20
|
-
|
|
21
|
-
# @!method down?
|
|
22
|
-
# Check if the item state == +DOWN+
|
|
23
|
-
# @return [Boolean]
|
|
24
|
-
|
|
25
|
-
# @!method up
|
|
26
|
-
# Send the +UP+ command to the item
|
|
27
|
-
# @return [RollershutterItem] +self+
|
|
28
|
-
|
|
29
|
-
# @!method down
|
|
30
|
-
# Send the +DOWN+ command to the item
|
|
31
|
-
# @return [RollershutterItem] +self+
|
|
32
|
-
|
|
33
|
-
# @!method stop
|
|
34
|
-
# Send the +STOP+ command to the item
|
|
35
|
-
# @return [RollershutterItem] +self+
|
|
36
|
-
|
|
37
|
-
# @!method move
|
|
38
|
-
# Send the +MOVE+ command to the item
|
|
39
|
-
# @return [RollershutterItem] +self+
|
|
40
|
-
|
|
41
|
-
# raw numbers translate directly to PercentType, not a DecimalType
|
|
42
|
-
# @!visibility private
|
|
43
|
-
def format_type(command)
|
|
44
|
-
return Types::PercentType.new(command) if command.is_a?(Numeric)
|
|
45
|
-
|
|
46
|
-
super
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Additions to Enumerable to allow easily filtering and commanding groups of items
|
|
4
|
-
module Enumerable
|
|
5
|
-
# Returns a new array of items that have at least one of the given tags
|
|
6
|
-
def tagged(*tags)
|
|
7
|
-
reject { |i| (tags & i.tags.to_a).empty? }
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
# Returns a new array of items that do not have any of the given tags
|
|
11
|
-
def not_tagged(*tags)
|
|
12
|
-
select { |i| (tags & i.tags.to_a).empty? }
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Returns a new array of items that are a member of at least one of the given groups
|
|
16
|
-
def member_of(*groups)
|
|
17
|
-
reject { |i| (groups.map(&:name) & i.group_names).empty? }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Returns a new array of items that are not a member of any of the given groups
|
|
21
|
-
def not_member_of(*groups)
|
|
22
|
-
select { |i| (groups.map(&:name) & i.group_names).empty? }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# Send a command to every item in the collection
|
|
26
|
-
def command(command)
|
|
27
|
-
each { |i| i.command(command) }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Update the state of every item in the collection
|
|
31
|
-
def update(state)
|
|
32
|
-
each { |i| i.update(state) }
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Returns the group members the elements
|
|
36
|
-
def members
|
|
37
|
-
select { |e| e.respond_to? :members }.flat_map(&:members)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# @!method refresh
|
|
41
|
-
# Send the +REFRESH+ command to every item in the collection
|
|
42
|
-
|
|
43
|
-
# @!method on
|
|
44
|
-
# Send the +ON+ command to every item in the collection
|
|
45
|
-
|
|
46
|
-
# @!method off
|
|
47
|
-
# Send the +OFF+ command to every item in the collection
|
|
48
|
-
|
|
49
|
-
# @!method up
|
|
50
|
-
# Send the +UP+ command to every item in the collection
|
|
51
|
-
|
|
52
|
-
# @!method down
|
|
53
|
-
# Send the +DOWN+ command to every item in the collection
|
|
54
|
-
|
|
55
|
-
# @!method stop
|
|
56
|
-
# Send the +STOP+ command to every item in the collection
|
|
57
|
-
|
|
58
|
-
# @!method move
|
|
59
|
-
# Send the +MOVE+ command to every item in the collection
|
|
60
|
-
|
|
61
|
-
# @!method increase
|
|
62
|
-
# Send the +INCREASE+ command to every item in the collection
|
|
63
|
-
|
|
64
|
-
# @!method decrease
|
|
65
|
-
# Send the +DECREASE+ command to every item in the collection
|
|
66
|
-
|
|
67
|
-
# @!method play
|
|
68
|
-
# Send the +PLAY+ command to every item in the collection
|
|
69
|
-
|
|
70
|
-
# @!method pause
|
|
71
|
-
# Send the +pause+ command to every item in the collection
|
|
72
|
-
|
|
73
|
-
# @!method rewind
|
|
74
|
-
# Send the +REWIND+ command to every item in the collection
|
|
75
|
-
|
|
76
|
-
# @!method fast_forward
|
|
77
|
-
# Send the +FAST_FORWARD+ command to every item in the collection
|
|
78
|
-
|
|
79
|
-
# @!method next
|
|
80
|
-
# Send the +NEXT+ command to every item in the collection
|
|
81
|
-
|
|
82
|
-
# @!method previous
|
|
83
|
-
# Send the +PREVIOUS+ command to every item in the collection
|
|
84
|
-
|
|
85
|
-
# @!visibility private
|
|
86
|
-
# can't use `include`, because Enumerable has already been included
|
|
87
|
-
# in other classes
|
|
88
|
-
def ensure
|
|
89
|
-
OpenHAB::DSL::Ensure::GenericItemDelegate.new(self)
|
|
90
|
-
end
|
|
91
|
-
end
|