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 +4 -4
- data/lib/openhab/dsl/monkey_patch/items/persistence.rb +18 -1
- data/lib/openhab/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01e9ddbd43a59fec9db3fa391d42cacb0cd1a03c7d116e995815df940847b28b
|
4
|
+
data.tar.gz: ef98bb992444788122499056470c2fde3fbfbdb6659a72228df0f2c46bd8cecb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/openhab/version.rb
CHANGED
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.
|
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
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|