openhab-scripting 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90af7470bbd47fa813a1a4a5a9083f178a36225ab6f9cfbd2ff1852cc0eb4c92
4
- data.tar.gz: 789d9c72ce03d498416bf53c86d6b7f895df8296d849f702b59398e831aad6f1
3
+ metadata.gz: 01e9ddbd43a59fec9db3fa391d42cacb0cd1a03c7d116e995815df940847b28b
4
+ data.tar.gz: ef98bb992444788122499056470c2fde3fbfbdb6659a72228df0f2c46bd8cecb
5
5
  SHA512:
6
- metadata.gz: 9066fe74d2d508e06ce9a62244a19a75470fcffb85bdbcaa2c899b5220a15da351ae4f55be08fb80d3c3222a1a26d16471420049b8621a60d143f16b867d7180
7
- data.tar.gz: 53d1df31662e7552566d6dd92237b862b32f988e4edf42bc95b44fff3af425e5a038771c2372e2fe71928867c41962907825a24e05fbf3e91ed31f5ff6ee2778
6
+ metadata.gz: 4499127b7c667c3290eb3d106624649ff04eff597eb95668c868bcaf5236f99a9149adf4b74e4750e2d092bc5cd7c3cc8b56b6470968f34c6324985b8bec7472
7
+ data.tar.gz: 93a18bda44e472326eb5952d089f5a8eb1f221bc566c861c9abee4cce08c21b5a8d29aa5168b05c5c54c3e61e613e1834ff01c39f18f57dcc2efc8d4c9eacbb5
@@ -9,6 +9,18 @@ module OpenHAB
9
9
  #
10
10
  module Persistence
11
11
  java_import Java::OrgOpenhabCoreTypesUtil::UnitUtils
12
+
13
+ # A wrapper for OpenHAB's HistoricItem that returns the state directly
14
+ class HistoricState < SimpleDelegator
15
+ attr_reader :timestamp, :state
16
+
17
+ def initialize(state, timestamp)
18
+ @state = state
19
+ @timestamp = timestamp
20
+ super(@state)
21
+ end
22
+ end
23
+
12
24
  # All persistence methods that could return a Quantity
13
25
  QUANTITY_METHODS = %i[average_since
14
26
  delta_since
@@ -45,13 +57,18 @@ module OpenHAB
45
57
  #
46
58
  def previous_state(service = nil, skip_equal: false)
47
59
  service ||= persistence_service
48
- PersistenceExtensions.previous_state(self, skip_equal, service&.to_s)
60
+ result = PersistenceExtensions.previous_state(self, skip_equal, service&.to_s)
61
+ HistoricState.new(quantify(result.state), result.timestamp)
49
62
  end
50
63
 
51
64
  PERSISTENCE_METHODS.each do |method|
52
65
  define_method(method) do |timestamp, service = nil|
53
66
  service ||= persistence_service
54
67
  result = PersistenceExtensions.public_send(method, self, to_zdt(timestamp), service&.to_s)
68
+ if result.is_a? Java::OrgOpenhabCorePersistence::HistoricItem
69
+ return HistoricState.new(quantify(result.state), result.timestamp)
70
+ end
71
+
55
72
  QUANTITY_METHODS.include?(method) ? quantify(result) : result
56
73
  end
57
74
  end
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '3.2.1'
8
+ VERSION = '3.3.0'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openhab-scripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-11 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler