Skip to content

Commit

Permalink
Persistence: add last_change and next_change (#277)
Browse files Browse the repository at this point in the history
Depends on: openhab/openhab-core#4259

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
  • Loading branch information
jimtng authored Jun 26, 2024
1 parent 9352a2d commit 46daa05
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion lib/openhab/core/items/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,20 @@ def persist(*args)
# @see last_update
# @since openHAB 4.2

%i[last_update next_update].each do |method|
# @!method last_change(service = nil)
# Returns the time the item was last changed.
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
# @return [ZonedDateTime, nil] The timestamp of the last update
# @since openHAB 4.2

# @!method next_change(service = nil)
# Returns the first future change time of the item.
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
# @return [ZonedDateTime, nil] The timestamp of the next update
# @see last_update
# @since openHAB 4.2

%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)

Expand Down
2 changes: 1 addition & 1 deletion spec/openhab/core/items/persistence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def call_method(method, item)
end
end

%i[last_update next_state next_update previous_state].each do |method|
%i[last_update next_update last_change next_change previous_state next_state].each do |method|
next unless OpenHAB::Core::Actions::PersistenceExtensions.respond_to?(method)

describe "##{method}" do
Expand Down

0 comments on commit 46daa05

Please sign in to comment.