Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
add persistence count_state_changes_since/between
Browse files Browse the repository at this point in the history
  • Loading branch information
jimtng committed Dec 11, 2022
1 parent 5c8ff24 commit 108a3b1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/openhab/core/items/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def timestamp
PERSISTENCE_METHODS = (QUANTITY_METHODS +
%i[changed_since?
count_since
count_state_changes_since
evolution_rate
historic_state
maximum_since
Expand Down Expand Up @@ -249,6 +250,19 @@ def timestamp
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
# @return [Integer] The number of values persisted for this item.

# @!method count_state_changes_since(timestamp, service = nil)
# Returns the number of changes in historic data points from a point in time until now.
# @param [#to_zoned_date_time] timestamp The point in time from which to search
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
# @return [Integer] The number of values persisted for this item.

# @!method count_state_changes_between(start, finish, service = nil)
# Returns the number of changes in historic data points between two points in time.
# @param [#to_zoned_date_time] start The point in time from which to search
# @param [#to_zoned_date_time] finish The point in time to which to search
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
# @return [Integer] The number of values persisted for this item.

%i[persist last_update].each do |method|
define_method(method) do |service = nil|
service ||= persistence_service
Expand Down

0 comments on commit 108a3b1

Please sign in to comment.