Module: OpenHAB::Core::Items::Persistence
- Included in:
 - GenericItem
 
- Defined in:
 - lib/openhab/core/items/persistence.rb
 
Overview
Items extensions to support openHAB's Persistence feature.
Defined Under Namespace
Classes: HistoricState
Instance Method Summary collapse
- 
  
    
      #average_between(start, finish, service = nil)  ⇒ DecimalType, ... 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the average value of the item's state between two points in time.
 - 
  
    
      #average_since(timestamp, service = nil)  ⇒ DecimalType, ... 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the average value of the item's state since 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.
 - 
  
    
      #count_between(start, finish, service = nil)  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the number of available historic 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 historic 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.
 - 
  
    
      #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.
 - 
  
    
      #deviation_between(start, finish, service = nil)  ⇒ DecimalType, ... 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the standard deviation of the item's state between two points in time.
 - 
  
    
      #deviation_since(timestamp, service = nil)  ⇒ DecimalType, ... 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the standard deviation of the item's state since the given time.
 - 
  
    
      #evolution_rate(timestamp, service = nil)  ⇒ DecimalType, ... 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the evolution rate of the item's state.
 - 
  
    
      #historic_state(timestamp, service = nil)  ⇒ HistoricState? 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the the item's state at the given time.
 - 
  
    
      #last_update(service = nil)  ⇒ ZonedDateTime? 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the time the item was last updated.
 - 
  
    
      #maximum_between(start, finish, service = nil)  ⇒ HistoricState? 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the maximum value of the item's state between two points in time.
 - 
  
    
      #maximum_since(timestamp, service = nil)  ⇒ HistoricState? 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the maximum value of the item's state since the given time.
 - 
  
    
      #minimum_between(start, finish, service = nil)  ⇒ HistoricState? 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the minimum value of the item's state between two points in time.
 - 
  
    
      #minimum_since(timestamp, service = nil)  ⇒ HistoricState? 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the minimum value of the item's state since the given time.
 - 
  
    
      #persist(service = nil)  ⇒ void 
    
    
  
  
  
  
  
  
  
  
  
    
Persists the state of the item.
 - 
  
    
      #previous_state(service = nil, skip_equal: false)  ⇒ HistoricState? 
    
    
  
  
  
  
  
  
  
  
  
    
Return the previous state of the item.
 - 
  
    
      #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.
 - 
  
    
      #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.
 - 
  
    
      #variance_between(start, finish, service = nil)  ⇒ DecimalType, ... 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the variance of the item's state between two points in time.
 - 
  
    
      #variance_since(timestamp, service = nil)  ⇒ DecimalType, ... 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the variance of the item's state since the given time.
 
Instance Method Details
#average_between(start, finish, service = nil) ⇒ DecimalType, ...
Returns the average value of the item's state between two points in time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 103
     | 
  
#average_since(timestamp, service = nil) ⇒ DecimalType, ...
Returns the average value of the item's state since the given time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 96
     | 
  
#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 177
     | 
  
#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 171
     | 
  
#count_between(start, finish, service = nil) ⇒ Integer
Returns the number of available historic data points between two points in time.
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 258
     | 
  
#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 252
     | 
  
#count_state_changes_between(start, finish, service = nil) ⇒ Integer Also known as: state_changes_between
Returns the number of changes in historic data points between two points in time.
      278 279 280 281 282 283  | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 278 %i[persist last_update].each do |method| define_method(method) do |service = nil| service ||= persistence_service Actions::PersistenceExtensions.public_send(method, self, service&.to_s) end end  | 
  
#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 265
     | 
  
#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 118
     | 
  
#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 111
     | 
  
#deviation_between(start, finish, service = nil) ⇒ DecimalType, ...
Returns the standard deviation of the item's state between two points in time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 133
     | 
  
#deviation_since(timestamp, service = nil) ⇒ DecimalType, ...
Returns the standard deviation of the item's state since the given time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 126
     | 
  
#evolution_rate(timestamp, service = nil) ⇒ DecimalType, ... #evolution_rate(start, finish, service = nil) ⇒ DecimalType, ...
Returns the evolution rate of the item's state
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 184
     | 
  
#historic_state(timestamp, service = nil) ⇒ HistoricState?
Returns the the item's state at the given time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 202
     | 
  
#last_update(service = nil) ⇒ ZonedDateTime?
Returns the time the item was last updated.
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 91
     | 
  
#maximum_between(start, finish, service = nil) ⇒ HistoricState?
Returns the maximum value of the item's state between two points in time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 216
     | 
  
#maximum_since(timestamp, service = nil) ⇒ HistoricState?
Returns the maximum value of the item's state since the given time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 209
     | 
  
#minimum_between(start, finish, service = nil) ⇒ HistoricState?
Returns the minimum value of the item's state between two points in time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 231
     | 
  
#minimum_since(timestamp, service = nil) ⇒ HistoricState?
Returns the minimum value of the item's state since the given time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 224
     | 
  
#persist(service = nil) ⇒ void
This method returns an undefined value.
Persists the state of the item
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 86
     | 
  
#previous_state(service = nil, skip_equal: false) ⇒ HistoricState?
Return the previous state of the item
      296 297 298 299 300  | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 296 def previous_state(service = nil, skip_equal: false) service ||= persistence_service result = Actions::PersistenceExtensions.previous_state(self, skip_equal, service&.to_s) HistoricState.new(quantify(result.state), result) if result end  | 
  
#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 148
     | 
  
#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 141
     | 
  
#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 245
     | 
  
#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 239
     | 
  
#variance_between(start, finish, service = nil) ⇒ DecimalType, ...
Returns the variance of the item's state between two points in time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 163
     | 
  
#variance_since(timestamp, service = nil) ⇒ DecimalType, ...
Returns the variance of the item's state since the given time
| 
       | 
    
      # File 'lib/openhab/core/items/persistence.rb', line 156
     |