Module: OpenHAB::Core::Items::Persistence
- Included in:
- Item
- Defined in:
- lib/openhab/core/items/persistence.rb
Overview
Items extensions to support openHAB's Persistence feature.
Defined Under Namespace
Classes: PersistedState
Constant Summary collapse
- HistoricState =
Deprecated.
Use PersistedState instead
- PersistedState
Instance Method Summary collapse
-
#all_states_between(start, finish, service = nil) ⇒ Array<PersistedState>
Returns all the states between two points in time.
-
#all_states_since(timestamp, service = nil) ⇒ Array<PersistedState>
Returns all the states from a point in time until now.
-
#all_states_until(timestamp, service = nil) ⇒ Array<PersistedState>
Returns all the states between now until the given time.
-
#average_between(start, finish, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the average value of the item's state between two points in time.
-
#average_since(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the average value of the item's state since the given time.
-
#average_until(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the average value of the item's state between now until the given time.
-
#changed_between?(start, finish, service = nil) ⇒ true, false
Whether the item's state changed between two points in time.
-
#changed_since?(timestamp, service = nil) ⇒ true, false
Whether the item's state has changed since the given time.
-
#changed_until?(timestamp, service = nil) ⇒ true, false
Whether the item's state has changed between now until the given time.
-
#count_between(start, finish, service = nil) ⇒ Integer
Returns the number of available data points between two points in time.
-
#count_since(timestamp, service = nil) ⇒ Integer
Returns the number of available historic data points from a point in time until now.
-
#count_state_changes_between(start, finish, service = nil) ⇒ Integer
(also: #state_changes_between)
Returns the number of changes in data points between two points in time.
-
#count_state_changes_since(timestamp, service = nil) ⇒ Integer
(also: #state_changes_since)
Returns the number of changes in historic data points from a point in time until now.
-
#count_state_changes_until(timestamp, service = nil) ⇒ Integer
(also: #state_changes_until)
Returns the number of changes in data points between now until the given time.
-
#count_until(timestamp, service = nil) ⇒ Integer
Returns the number of available data points between now until the given time.
-
#delta_between(start, finish, service = nil) ⇒ DecimalType, ...
Returns the difference value of the item's state between two points in time.
-
#delta_since(timestamp, service = nil) ⇒ DecimalType, ...
Returns the difference value of the item's state since the given time.
-
#delta_until(timestamp, service = nil) ⇒ DecimalType, ...
Returns the difference value of the item's state between now until the given time.
-
#deviation_between(start, finish, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the standard deviation of the item's state between two points in time.
-
#deviation_since(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the standard deviation of the item's state since the given time.
-
#deviation_until(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the standard deviation of the item's state beetween now until the given time.
-
#evolution_rate(start, finish_or_service = nil, service = nil) ⇒ Object
deprecated
Deprecated.
OH 4.2 this method is deprecated in OH 4.2 and may be removed in a future version
-
#evolution_rate_between(start, finish, service = nil) ⇒ DecimalType?
Returns the evolution rate of the item's state between two points in time.
-
#evolution_rate_since(timestamp, service = nil) ⇒ DecimalType?
Returns the evolution rate of the item's state since the given time.
-
#evolution_rate_until(timestamp, service = nil) ⇒ DecimalType?
Returns the evolution rate of the item's state between now until the given time.
-
#historic_state(timestamp, service = nil) ⇒ PersistedState?
deprecated
Deprecated.
In openHAB 4.2, use #persisted_state instead
-
#last_change(service = nil) ⇒ ZonedDateTime?
Returns the time the item was last changed.
-
#last_update(service = nil) ⇒ ZonedDateTime?
Returns the time the item was last updated.
-
#maximum_between(start, finish, service = nil) ⇒ PersistedState?
Returns the maximum value of the item's state between two points in time.
-
#maximum_since(timestamp, service = nil) ⇒ PersistedState?
Returns the maximum value of the item's state since the given time.
-
#maximum_until(timestamp, service = nil) ⇒ PersistedState?
Returns the maximum value of the item's state between now until the given time.
-
#median_between(start, finish, service = nil) ⇒ DecimalType, ...
Returns the median of the item's state between two points in time.
-
#median_since(timestamp, service = nil) ⇒ DecimalType, ...
Returns the median of the item's state since the given time.
-
#median_until(timestamp, service = nil) ⇒ DecimalType, ...
Returns the median of the item's state beetween now until the given time.
-
#minimum_between(start, finish, service = nil) ⇒ PersistedState?
Returns the minimum value of the item's state between two points in time.
-
#minimum_since(timestamp, service = nil) ⇒ PersistedState?
Returns the minimum value of the item's state since the given time.
-
#minimum_until(timestamp, service = nil) ⇒ PersistedState?
Returns the minimum value of the item's state between now until the given time.
-
#next_change(service = nil) ⇒ ZonedDateTime?
Returns the first future change time of the item.
-
#next_state(service = nil, skip_equal: false) ⇒ PersistedState?
Return the next state of the item.
-
#next_update(service = nil) ⇒ ZonedDateTime?
Returns the first future update time of the item.
-
#persist(*args) ⇒ Object
Persist item state to the persistence service.
-
#persisted_state(timestamp, service = nil) ⇒ PersistedState?
Returns the the item's state at the given time.
-
#previous_state(service = nil, skip_equal: false) ⇒ PersistedState?
Return the previous state of the item.
-
#remove_all_states_between(start, finish, service = nil) ⇒ void
Removes persisted data points between two points in time.
-
#remove_all_states_since(timestamp, service = nil) ⇒ void
Removes persisted data points since a certain point in time.
-
#remove_all_states_until(timestamp, service = nil) ⇒ void
Removes persisted data points from now until the given point in time.
-
#riemann_sum_between(start, finish, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the Riemann sum of the states between two points in time.
-
#riemann_sum_since(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the Riemann sum of the states since a certain point in time.
-
#riemann_sum_until(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the Riemann sum of the states between now until a certain point in time.
-
#sum_between(start, finish, service = nil) ⇒ DecimalType, ...
Returns the sum of the item's state between two points in time.
-
#sum_since(timestamp, service = nil) ⇒ DecimalType, ...
Returns the sum of the item's state since the given time.
-
#sum_until(timestamp, service = nil) ⇒ DecimalType, ...
Returns the sum of the item's state between now until the given time.
-
#updated_between?(start, finish, service = nil) ⇒ true, false
Whether the item's state was updated between two points in time.
-
#updated_since?(timestamp, service = nil) ⇒ true, false
Whether the item's state has been updated since the given time.
-
#updated_until?(timestamp, service = nil) ⇒ true, false
Whether the item's state will be updated between now until the given time.
-
#variance_between(start, finish, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the variance of the item's state between two points in time.
-
#variance_since(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the variance of the item's state since the given time.
-
#variance_until(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the variance of the item's state between now until the given time.
Instance Method Details
#all_states_between(start, finish, service = nil) ⇒ Array<PersistedState>
Returns all the states between two points in time.
|
# File 'lib/openhab/core/items/persistence.rb', line 483
|
#all_states_since(timestamp, service = nil) ⇒ Array<PersistedState>
Returns all the states from a point in time until now.
|
# File 'lib/openhab/core/items/persistence.rb', line 469
|
#all_states_until(timestamp, service = nil) ⇒ Array<PersistedState>
Returns all the states between now until the given time.
|
# File 'lib/openhab/core/items/persistence.rb', line 476
|
#average_between(start, finish, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the average value of the item's state between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 135
|
#average_since(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the average value of the item's state since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 114
|
#average_until(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the average value of the item's state between now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 124
|
#changed_between?(start, finish, service = nil) ⇒ true, false
Whether the item's state changed between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 294
|
#changed_since?(timestamp, service = nil) ⇒ true, false
Whether the item's state has changed since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 281
|
#changed_until?(timestamp, service = nil) ⇒ true, false
Whether the item's state has changed between now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 287
|
#count_between(start, finish, service = nil) ⇒ Integer
Returns the number of available data points between two points in time.
|
# File 'lib/openhab/core/items/persistence.rb', line 442
|
#count_since(timestamp, service = nil) ⇒ Integer
Returns the number of available historic data points from a point in time until now.
|
# File 'lib/openhab/core/items/persistence.rb', line 429
|
#count_state_changes_between(start, finish, service = nil) ⇒ Integer Also known as: state_changes_between
Returns the number of changes in data points between two points in time.
|
# File 'lib/openhab/core/items/persistence.rb', line 462
|
#count_state_changes_since(timestamp, service = nil) ⇒ Integer Also known as: state_changes_since
Returns the number of changes in historic data points from a point in time until now.
|
# File 'lib/openhab/core/items/persistence.rb', line 449
|
#count_state_changes_until(timestamp, service = nil) ⇒ Integer Also known as: state_changes_until
Returns the number of changes in data points between now until the given time.
|
# File 'lib/openhab/core/items/persistence.rb', line 455
|
#count_until(timestamp, service = nil) ⇒ Integer
Returns the number of available data points between now until the given time.
|
# File 'lib/openhab/core/items/persistence.rb', line 435
|
#delta_between(start, finish, service = nil) ⇒ DecimalType, ...
Returns the difference value of the item's state between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 161
|
#delta_since(timestamp, service = nil) ⇒ DecimalType, ...
Returns the difference value of the item's state since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 146
|
#delta_until(timestamp, service = nil) ⇒ DecimalType, ...
Returns the difference value of the item's state between now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 153
|
#deviation_between(start, finish, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the standard deviation of the item's state between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 190
|
#deviation_since(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the standard deviation of the item's state since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 169
|
#deviation_until(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the standard deviation of the item's state beetween now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 179
|
#evolution_rate(start, finish_or_service = nil, service = nil) ⇒ Object
OH 4.2 this method is deprecated in OH 4.2 and may be removed in a future version
|
# File 'lib/openhab/core/items/persistence.rb', line 301
|
#evolution_rate_between(start, finish, service = nil) ⇒ DecimalType?
Returns the evolution rate of the item's state between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 338
|
#evolution_rate_since(timestamp, service = nil) ⇒ DecimalType?
Returns the evolution rate of the item's state since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 322
|
#evolution_rate_until(timestamp, service = nil) ⇒ DecimalType?
Returns the evolution rate of the item's state between now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 330
|
#historic_state(timestamp, service = nil) ⇒ PersistedState?
In openHAB 4.2, use #persisted_state instead
Returns the the item's state at the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 347
|
#last_change(service = nil) ⇒ ZonedDateTime?
Returns the time the item was last changed.
|
# File 'lib/openhab/core/items/persistence.rb', line 634
|
#last_update(service = nil) ⇒ ZonedDateTime?
Returns the time the item was last updated.
|
# File 'lib/openhab/core/items/persistence.rb', line 622
|
#maximum_between(start, finish, service = nil) ⇒ PersistedState?
Returns the maximum value of the item's state between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 378
|
#maximum_since(timestamp, service = nil) ⇒ PersistedState?
Returns the maximum value of the item's state since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 363
|
#maximum_until(timestamp, service = nil) ⇒ PersistedState?
Returns the maximum value of the item's state between now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 370
|
#median_between(start, finish, service = nil) ⇒ DecimalType, ...
Returns the median of the item's state between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 217
|
#median_since(timestamp, service = nil) ⇒ DecimalType, ...
Returns the median of the item's state since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 201
|
#median_until(timestamp, service = nil) ⇒ DecimalType, ...
Returns the median of the item's state beetween now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 209
|
#minimum_between(start, finish, service = nil) ⇒ PersistedState?
Returns the minimum value of the item's state between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 401
|
#minimum_since(timestamp, service = nil) ⇒ PersistedState?
Returns the minimum value of the item's state since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 386
|
#minimum_until(timestamp, service = nil) ⇒ PersistedState?
Returns the minimum value of the item's state between now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 393
|
#next_change(service = nil) ⇒ ZonedDateTime?
Returns the first future change time of the item.
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
# File 'lib/openhab/core/items/persistence.rb', line 647 %i[last_update next_update last_change next_change].each do |method| # @deprecated OH 4.1 remove this guard when dropping OH 4.1 next unless Actions::PersistenceExtensions.respond_to?(method) class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{method}(service = nil) # def last_update(service = nil) service ||= persistence_service # service ||= persistence_service result = Actions::PersistenceExtensions.#{method}( # result = Actions::PersistenceExtensions.last_update( self, # self, service&.to_s # service&.to_s ) # ) wrap_result(result) # wrap_result(result) end # end RUBY end |
#next_state(service = nil, skip_equal: false) ⇒ PersistedState?
Return the next state of the item
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
# File 'lib/openhab/core/items/persistence.rb', line 687 %i[previous_state next_state].each do |method| # @deprecated OH 4.1 remove this guard when dropping OH 4.1 next unless Actions::PersistenceExtensions.respond_to?(method) class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{method}(service = nil, skip_equal: false) # def previous_state(service = nil, skip_equal: false) service ||= persistence_service # service ||= persistence_service result = Actions::PersistenceExtensions.#{method}( # result = Actions::PersistenceExtensions.previous_state( self, # self, skip_equal, # skip_equal, service&.to_s # service&.to_s ) # ) wrap_result(result, quantify: true) # wrap_result(result, quantify: true) end # end RUBY end |
#next_update(service = nil) ⇒ ZonedDateTime?
Returns the first future update time of the item.
|
# File 'lib/openhab/core/items/persistence.rb', line 627
|
#persist(service = nil) ⇒ void #persist(timestamp, state, service = nil) ⇒ void #persist(time_series, service = nil) ⇒ void
Persist item state to the persistence service
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
# File 'lib/openhab/core/items/persistence.rb', line 567 def persist(*args) # @deprecated OH 4.1 this if block content can be removed when dropping OH 4.1 support if Core.version < Core::V4_2 raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0..1)" if args.size > 1 service = args.last || persistence_service Actions::PersistenceExtensions.persist(self, service&.to_s) return end first_arg = args.first if first_arg.is_a?(TimeSeries) if args.size > 2 raise ArgumentError, "wrong number of arguments to persist a time series (given #{args.size}, expected 1..2)" end service = args[1] || persistence_service Actions::PersistenceExtensions.java_send :persist, [Item.java_class, Types::TimeSeries.java_class, java.lang.String], self, first_arg, service&.to_s elsif first_arg.respond_to?(:to_zoned_date_time) unless args.size.between?(2, 3) raise ArgumentError, "wrong number of arguments to persist a state (given #{args.size}, expected 2..3)" end timestamp = first_arg.to_zoned_date_time state = format_update(args[1]) service = args[2] || persistence_service Actions::PersistenceExtensions.java_send :persist, [Item.java_class, ZonedDateTime.java_class, org.openhab.core.types.State, java.lang.String], self, timestamp, state, service&.to_s else if args.size > 1 raise ArgumentError, "wrong number of arguments to persist the current state (given #{args.size}, expected 0..1)" end service = first_arg || persistence_service Actions::PersistenceExtensions.java_send :persist, [Item.java_class, java.lang.String], self, service&.to_s end end |
#persisted_state(timestamp, service = nil) ⇒ PersistedState?
Returns the the item's state at the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 355
|
#previous_state(service = nil, skip_equal: false) ⇒ PersistedState?
Return the previous state of the item
|
# File 'lib/openhab/core/items/persistence.rb', line 663
|
#remove_all_states_between(start, finish, service = nil) ⇒ void
This method returns an undefined value.
Removes persisted data points between two points in time.
|
# File 'lib/openhab/core/items/persistence.rb', line 536
|
#remove_all_states_since(timestamp, service = nil) ⇒ void
This method returns an undefined value.
Removes persisted data points since a certain point in time.
|
# File 'lib/openhab/core/items/persistence.rb', line 522
|
#remove_all_states_until(timestamp, service = nil) ⇒ void
This method returns an undefined value.
Removes persisted data points from now until the given point in time.
|
# File 'lib/openhab/core/items/persistence.rb', line 529
|
#riemann_sum_between(start, finish, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the Riemann sum of the states between two points in time.
|
# File 'lib/openhab/core/items/persistence.rb', line 511
|
#riemann_sum_since(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the Riemann sum of the states since a certain point in time.
|
# File 'lib/openhab/core/items/persistence.rb', line 491
|
#riemann_sum_until(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the Riemann sum of the states between now until a certain point in time.
|
# File 'lib/openhab/core/items/persistence.rb', line 501
|
#sum_between(start, finish, service = nil) ⇒ DecimalType, ...
Returns the sum of the item's state between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 241
|
#sum_since(timestamp, service = nil) ⇒ DecimalType, ...
Returns the sum of the item's state since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 226
|
#sum_until(timestamp, service = nil) ⇒ DecimalType, ...
Returns the sum of the item's state between now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 233
|
#updated_between?(start, finish, service = nil) ⇒ true, false
Whether the item's state was updated between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 422
|
#updated_since?(timestamp, service = nil) ⇒ true, false
Whether the item's state has been updated since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 409
|
#updated_until?(timestamp, service = nil) ⇒ true, false
Whether the item's state will be updated between now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 415
|
#variance_between(start, finish, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the variance of the item's state between two points in time
|
# File 'lib/openhab/core/items/persistence.rb', line 270
|
#variance_since(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the variance of the item's state since the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 249
|
#variance_until(timestamp, service = nil, riemann_type: nil) ⇒ DecimalType, ...
Returns the variance of the item's state between now until the given time
|
# File 'lib/openhab/core/items/persistence.rb', line 259
|