diff --git a/lib/openhab/core/items/persistence.rb b/lib/openhab/core/items/persistence.rb index 97363edd0..7a1bbe8ab 100644 --- a/lib/openhab/core/items/persistence.rb +++ b/lib/openhab/core/items/persistence.rb @@ -88,10 +88,14 @@ class PersistedState < SimpleDelegator # @!attribute [r] timestamp # @return [ZonedDateTime] + # @!attribute [r] instant + # @return [Instant] The timestamp as an Instant + # @since openHAB 4.3 + # @!attribute [r] name # @return [String] Item name - delegate %i[timestamp name] => :@historic_item + delegate %i[timestamp instant name] => :@historic_item def initialize(historic_item, state = nil) @historic_item = historic_item diff --git a/spec/openhab/core/items/persistence_spec.rb b/spec/openhab/core/items/persistence_spec.rb index cb757d574..93b9fdd36 100644 --- a/spec/openhab/core/items/persistence_spec.rb +++ b/spec/openhab/core/items/persistence_spec.rb @@ -189,6 +189,10 @@ def initialize(timestamp, state, name) expect(max).to be_a described_class::PersistedState expect(max).to eql max.state expect(max.timestamp).to be_a ZonedDateTime + # @deprecated OH 4.2 - Remove if guard when dropping oh 4.2 support + if OpenHAB::Core.version >= OpenHAB::Core::V4_3 && OpenHAB::Core::Items::Persistence::PersistedState.instance_methods.include?(:instant) + expect(max.instant).to be_a Instant + end end it "is inspectable" do