openhab-scripting 5.36.2 → 5.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/openhab/core/items/persistence.rb +137 -43
- data/lib/openhab/dsl/version.rb +1 -1
- data/lib/openhab/yard/markdown_helper.rb +3 -0
- 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: 3c7147931d90e0b4f5c7d16fb324ac46f6ddd579e25c32245c49fc1c4a770120
|
4
|
+
data.tar.gz: 718a8d07104975de5fd75900ba97b743319e8a18ff4076dc811ae7b5b0ffbdc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0998824497c882bc59e935f13a28aeda241c0f399428ab90403b817e4b4f664db37d2c2225b9ff356535e3cb2ae478f8b091ab09cfda1d091142ae7b0e6ccc85'
|
7
|
+
data.tar.gz: 72037d1a9d371458716fbc88955858d6a615dfc089878226cbb0109706df7c7a9d77f9ebc9001581a0f379e8785a7f752d060369dacb152bdefb5be9bdcbbc89
|
@@ -111,28 +111,37 @@ module OpenHAB
|
|
111
111
|
# @deprecated Use {PersistedState} instead
|
112
112
|
HistoricState = PersistedState
|
113
113
|
|
114
|
-
# @!method average_since(timestamp, service = nil)
|
114
|
+
# @!method average_since(timestamp, service = nil, riemann_type: nil)
|
115
115
|
# Returns the average value of the item's state since the given time
|
116
116
|
# @param [#to_zoned_date_time] timestamp The point in time from which to search
|
117
117
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
118
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
119
|
+
# If nil, :left is used.
|
118
120
|
# @return [DecimalType, QuantityType, nil] The average value since `timestamp`,
|
119
121
|
# or nil if no previous states could be found.
|
122
|
+
# @since openHAB 5.0 riemann_type parameter added
|
120
123
|
|
121
|
-
# @!method average_until(timestamp, service = nil)
|
124
|
+
# @!method average_until(timestamp, service = nil, riemann_type: nil)
|
122
125
|
# Returns the average value of the item's state between now until the given time
|
123
126
|
# @param [#to_zoned_date_time] timestamp The point in time until which to search
|
124
127
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
128
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
129
|
+
# If nil, :left is used.
|
125
130
|
# @return [DecimalType, QuantityType, nil] The average value until `timestamp`,
|
126
131
|
# or nil if no future states could be found.
|
127
132
|
# @since openHAB 4.2
|
133
|
+
# @since openHAB 5.0 riemann_type parameter added
|
128
134
|
|
129
|
-
# @!method average_between(start, finish, service = nil)
|
135
|
+
# @!method average_between(start, finish, service = nil, riemann_type: nil)
|
130
136
|
# Returns the average value of the item's state between two points in time
|
131
137
|
# @param [#to_zoned_date_time] start The point in time from which to search
|
132
138
|
# @param [#to_zoned_date_time] finish The point in time to which to search
|
133
139
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
140
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
141
|
+
# If nil, :left is used.
|
134
142
|
# @return [DecimalType, QuantityType, nil] The average value between `start` and `finish`,
|
135
143
|
# or nil if no states could be found.
|
144
|
+
# @since openHAB 5.0 riemann_type parameter added
|
136
145
|
|
137
146
|
# @!method delta_since(timestamp, service = nil)
|
138
147
|
# Returns the difference value of the item's state since the given time
|
@@ -157,28 +166,37 @@ module OpenHAB
|
|
157
166
|
# @return [DecimalType, QuantityType, nil] The difference value between `start` and `finish`,
|
158
167
|
# or nil if no states could be found.
|
159
168
|
|
160
|
-
# @!method deviation_since(timestamp, service = nil)
|
169
|
+
# @!method deviation_since(timestamp, service = nil, riemann_type: nil)
|
161
170
|
# Returns the standard deviation of the item's state since the given time
|
162
171
|
# @param [#to_zoned_date_time] timestamp The point in time from which to search
|
163
172
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
173
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
174
|
+
# If nil, :left is used.
|
164
175
|
# @return [DecimalType, QuantityType, nil] The standard deviation since `timestamp`,
|
165
176
|
# or nil if no previous states could be found.
|
177
|
+
# @since openHAB 5.0 riemann_type parameter added
|
166
178
|
|
167
|
-
# @!method deviation_until(timestamp, service = nil)
|
179
|
+
# @!method deviation_until(timestamp, service = nil, riemann_type: nil)
|
168
180
|
# Returns the standard deviation of the item's state beetween now until the given time
|
169
181
|
# @param [#to_zoned_date_time] timestamp The point in time until which to search
|
170
182
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
183
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
184
|
+
# If nil, :left is used.
|
171
185
|
# @return [DecimalType, QuantityType, nil] The standard deviation until `timestamp`,
|
172
186
|
# or nil if no future states could be found.
|
173
187
|
# @since openHAB 4.2
|
188
|
+
# @since openHAB 5.0 riemann_type parameter added
|
174
189
|
|
175
|
-
# @!method deviation_between(start, finish, service = nil)
|
190
|
+
# @!method deviation_between(start, finish, service = nil, riemann_type: nil)
|
176
191
|
# Returns the standard deviation of the item's state between two points in time
|
177
192
|
# @param [#to_zoned_date_time] start The point in time from which to search
|
178
193
|
# @param [#to_zoned_date_time] finish The point in time to which to search
|
179
194
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
195
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
196
|
+
# If nil, :left is used.
|
180
197
|
# @return [DecimalType, QuantityType, nil] The standard deviation between `start` and `finish`,
|
181
198
|
# or nil if no states could be found.
|
199
|
+
# @since openHAB 5.0 riemann_type parameter added
|
182
200
|
|
183
201
|
# @!method median_since(timestamp, service = nil)
|
184
202
|
# Returns the median of the item's state since the given time
|
@@ -228,28 +246,37 @@ module OpenHAB
|
|
228
246
|
# @return [DecimalType, QuantityType, nil] The sum between `start` and `finish`,
|
229
247
|
# or nil if no states could be found.
|
230
248
|
|
231
|
-
# @!method variance_since(timestamp, service = nil)
|
249
|
+
# @!method variance_since(timestamp, service = nil, riemann_type: nil)
|
232
250
|
# Returns the variance of the item's state since the given time
|
233
251
|
# @param [#to_zoned_date_time] timestamp The point in time from which to search
|
234
252
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
253
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
254
|
+
# If nil, :left is used.
|
235
255
|
# @return [DecimalType, QuantityType, nil] The variance since `timestamp`,
|
236
256
|
# or nil if no previous states could be found.
|
257
|
+
# @since openHAB 5.0 riemann_type parameter added
|
237
258
|
|
238
|
-
# @!method variance_until(timestamp, service = nil)
|
259
|
+
# @!method variance_until(timestamp, service = nil, riemann_type: nil)
|
239
260
|
# Returns the variance of the item's state between now until the given time
|
240
261
|
# @param [#to_zoned_date_time] timestamp The point in time until which to search
|
241
262
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
263
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
264
|
+
# If nil, :left is used.
|
242
265
|
# @return [DecimalType, QuantityType, nil] The variance until `timestamp`,
|
243
266
|
# or nil if no future states could be found.
|
244
267
|
# @since openHAB 4.2
|
268
|
+
# @since openHAB 5.0 riemann_type parameter added
|
245
269
|
|
246
|
-
# @!method variance_between(start, finish, service = nil)
|
270
|
+
# @!method variance_between(start, finish, service = nil, riemann_type: nil)
|
247
271
|
# Returns the variance of the item's state between two points in time
|
248
272
|
# @param [#to_zoned_date_time] start The point in time from which to search
|
249
273
|
# @param [#to_zoned_date_time] finish The point in time to which to search
|
250
274
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
275
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
276
|
+
# If nil, :left is used.
|
251
277
|
# @return [DecimalType, QuantityType, nil] The variance between `start` and `finish`,
|
252
278
|
# or nil if no states could be found.
|
279
|
+
# @since openHAB 5.0 riemann_type parameter added
|
253
280
|
|
254
281
|
# @!method changed_since?(timestamp, service = nil)
|
255
282
|
# Whether the item's state has changed since the given time
|
@@ -461,6 +488,37 @@ module OpenHAB
|
|
461
488
|
# @return [Array<PersistedState>] An array of {PersistedState} persisted for this item.
|
462
489
|
# @since openHAB 4.0
|
463
490
|
|
491
|
+
# @!method riemann_sum_since(timestamp, service = nil, riemann_type: nil)
|
492
|
+
# Returns the Riemann sum of the states since a certain point in time.
|
493
|
+
# @param [#to_zoned_date_time] timestamp The point in time from which to search
|
494
|
+
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
495
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
496
|
+
# If nil, :left is used.
|
497
|
+
# @return [DecimalType, QuantityType, nil] The riemann sum since `timestamp`,
|
498
|
+
# or nil if no previous states could be found.
|
499
|
+
# @since openHAB 5.0
|
500
|
+
|
501
|
+
# @!method riemann_sum_until(timestamp, service = nil, riemann_type: nil)
|
502
|
+
# Returns the Riemann sum of the states between now until a certain point in time.
|
503
|
+
# @param [#to_zoned_date_time] timestamp The point in time until which to search
|
504
|
+
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
505
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
506
|
+
# If nil, :left is used.
|
507
|
+
# @return [DecimalType, QuantityType, nil] The riemann sum until `timestamp`,
|
508
|
+
# or nil if no previous states could be found.
|
509
|
+
# @since openHAB 5.0
|
510
|
+
|
511
|
+
# @!method riemann_sum_between(start, finish, service = nil, riemann_type: nil)
|
512
|
+
# Returns the Riemann sum of the states between two points in time.
|
513
|
+
# @param [#to_zoned_date_time] start The point in time from which to search
|
514
|
+
# @param [#to_zoned_date_time] finish The point in time to which to search
|
515
|
+
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
516
|
+
# @param [:left, :midpoint, :right, :trapezoidal] riemann_type An optional approximation type for Riemann sum.
|
517
|
+
# If nil, :left is used.
|
518
|
+
# @return [DecimalType, QuantityType, nil] The riemann sum between `start` and `finish`,
|
519
|
+
# or nil if no previous states could be found.
|
520
|
+
# @since openHAB 5.0
|
521
|
+
|
464
522
|
# @!method remove_all_states_since(timestamp, service = nil)
|
465
523
|
# Removes persisted data points since a certain point in time.
|
466
524
|
# @param [#to_zoned_date_time] timestamp The point in time from which to remove
|
@@ -645,76 +703,103 @@ module OpenHAB
|
|
645
703
|
|
646
704
|
class << self
|
647
705
|
# @!visibility private
|
648
|
-
def def_persistence_method(method, quantify: false)
|
706
|
+
def def_persistence_method(method, quantify: false, riemann_param: nil)
|
649
707
|
method = method.to_s.dup
|
650
708
|
suffix = method.delete_suffix!("?") && "?"
|
709
|
+
riemann_arg = nil
|
710
|
+
|
711
|
+
if riemann_param
|
712
|
+
riemann_param = ", riemann_type: nil"
|
713
|
+
# @deprecated OH4.3 remove if guard when dropping OH 4.3
|
714
|
+
if Actions::PersistenceExtensions.const_defined?(:RiemannType)
|
715
|
+
riemann_arg = "to_riemann_type(riemann_type),"
|
716
|
+
end
|
717
|
+
end
|
651
718
|
|
652
719
|
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
653
|
-
def #{method}#{suffix}(timestamp, service = nil)
|
654
|
-
service ||= persistence_service
|
655
|
-
result = Actions::PersistenceExtensions.#{method}(
|
656
|
-
self,
|
657
|
-
timestamp.to_zoned_date_time,
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
720
|
+
def #{method}#{suffix}(timestamp, service = nil#{riemann_param}) # def changed_since?(timestamp, service = nil, riemann_type: nil)
|
721
|
+
service ||= persistence_service # service ||= persistence_service
|
722
|
+
result = Actions::PersistenceExtensions.#{method}( # result = Actions::PersistenceExtensions.average_since(
|
723
|
+
self, # self,
|
724
|
+
timestamp.to_zoned_date_time, # timestamp.to_zoned_date_time,
|
725
|
+
#{riemann_arg} # to_riemann_type(riemann_type),
|
726
|
+
service&.to_s # service&.to_s
|
727
|
+
) # )
|
728
|
+
wrap_result(result, quantify: #{quantify}) # wrap_result(result, quantify: false)
|
729
|
+
end # end
|
662
730
|
RUBY
|
663
731
|
end
|
664
732
|
|
665
733
|
# @!visibility private
|
666
|
-
def def_persistence_methods(method, quantify: false)
|
734
|
+
def def_persistence_methods(method, quantify: false, riemann_param: nil)
|
667
735
|
method = method.to_s.dup
|
668
736
|
suffix = method.delete_suffix!("?") && "?"
|
737
|
+
riemann_arg = nil
|
669
738
|
|
670
|
-
def_persistence_method("#{method}_since#{suffix}", quantify:)
|
739
|
+
def_persistence_method("#{method}_since#{suffix}", quantify:, riemann_param:)
|
671
740
|
# @deprecated OH 4.1 remove if guard, keeping the content, when dropping OH 4.1
|
672
741
|
if OpenHAB::Core.version >= OpenHAB::Core::V4_2
|
673
|
-
def_persistence_method("#{method}_until#{suffix}", quantify:)
|
742
|
+
def_persistence_method("#{method}_until#{suffix}", quantify:, riemann_param:)
|
743
|
+
end
|
744
|
+
|
745
|
+
if riemann_param
|
746
|
+
riemann_param = ", riemann_type: nil"
|
747
|
+
# @deprecated OH4.3 remove if guard when dropping OH 4.3
|
748
|
+
if Actions::PersistenceExtensions.const_defined?(:RiemannType)
|
749
|
+
riemann_arg = "to_riemann_type(riemann_type),"
|
750
|
+
end
|
674
751
|
end
|
675
752
|
|
676
753
|
method = "#{method}_between"
|
677
754
|
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
678
|
-
def #{method}#{suffix}(start, finish, service = nil)
|
679
|
-
service ||= persistence_service
|
680
|
-
result = Actions::PersistenceExtensions.#{method}(
|
681
|
-
self,
|
682
|
-
start.to_zoned_date_time,
|
683
|
-
finish.to_zoned_date_time,
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
755
|
+
def #{method}#{suffix}(start, finish, service = nil#{riemann_param}) # def changed_between?(start, finish, service = nil, riemann_type: nil)
|
756
|
+
service ||= persistence_service # service ||= persistence_service
|
757
|
+
result = Actions::PersistenceExtensions.#{method}( # result = Actions::PersistenceExtensions.average_between(
|
758
|
+
self, # self,
|
759
|
+
start.to_zoned_date_time, # start.to_zoned_date_time,
|
760
|
+
finish.to_zoned_date_time, # finish.to_zoned_date_time,
|
761
|
+
#{riemann_arg} # to_riemann_type(riemann_type),
|
762
|
+
service&.to_s # service&.to_s
|
763
|
+
) # )
|
764
|
+
wrap_result(result, quantify: #{quantify}) # wrap_result(result, quantify: false)
|
765
|
+
end # end
|
688
766
|
RUBY
|
689
767
|
end
|
690
768
|
end
|
691
769
|
|
692
|
-
|
693
|
-
def_persistence_methods(:
|
694
|
-
def_persistence_methods(:delta, quantify: true)
|
695
|
-
def_persistence_methods(:deviation, quantify: true)
|
696
|
-
def_persistence_methods(:sum, quantify: true)
|
697
|
-
def_persistence_methods(:variance, quantify: true)
|
698
|
-
|
770
|
+
# arranged in alphabetical order
|
771
|
+
def_persistence_methods(:average, quantify: true, riemann_param: true)
|
699
772
|
def_persistence_methods(:changed?)
|
700
773
|
def_persistence_methods(:count)
|
774
|
+
|
701
775
|
def_persistence_methods(:count_state_changes)
|
702
776
|
alias_method :state_changes_since, :count_state_changes_since
|
703
777
|
alias_method :state_changes_until, :count_state_changes_until if OpenHAB::Core.version >= OpenHAB::Core::V4_2
|
704
778
|
alias_method :state_changes_between, :count_state_changes_between
|
705
779
|
|
780
|
+
def_persistence_methods(:delta, quantify: true)
|
781
|
+
def_persistence_methods(:deviation, quantify: true, riemann_param: true)
|
782
|
+
|
706
783
|
# @deprecated OH 4.2 - this still exists in OH 4.2 but logs a deprecation warning
|
707
784
|
def_persistence_method(:historic_state, quantify: true)
|
708
785
|
|
709
|
-
def_persistence_methods(:maximum, quantify: true)
|
710
|
-
def_persistence_methods(:minimum, quantify: true)
|
711
|
-
def_persistence_methods(:updated?)
|
712
|
-
|
713
786
|
def_persistence_methods(:get_all_states, quantify: true)
|
714
787
|
alias_method :all_states_since, :get_all_states_since
|
715
788
|
alias_method :all_states_until, :get_all_states_until if OpenHAB::Core.version >= OpenHAB::Core::V4_2
|
716
789
|
alias_method :all_states_between, :get_all_states_between
|
717
790
|
|
791
|
+
def_persistence_methods(:maximum, quantify: true)
|
792
|
+
def_persistence_methods(:minimum, quantify: true)
|
793
|
+
def_persistence_methods(:median, quantify: true) if OpenHAB::Core.version >= OpenHAB::Core::V4_3
|
794
|
+
# @deprecated OH4.3 remove if guard when dropping OH 4.3
|
795
|
+
if Actions::PersistenceExtensions.const_defined?(:RiemannType)
|
796
|
+
# riemann_sum methods were added in OH 5.0 which already quantifies the result in core
|
797
|
+
def_persistence_methods(:riemann_sum, riemann_param: true)
|
798
|
+
end
|
799
|
+
def_persistence_methods(:sum, quantify: true)
|
800
|
+
def_persistence_methods(:updated?)
|
801
|
+
def_persistence_methods(:variance, quantify: true, riemann_param: true)
|
802
|
+
|
718
803
|
if OpenHAB::Core.version >= OpenHAB::Core::V4_2
|
719
804
|
def_persistence_method(:persisted_state) # already quantified in core
|
720
805
|
|
@@ -805,6 +890,15 @@ module OpenHAB
|
|
805
890
|
def persistence_service
|
806
891
|
Thread.current[:openhab_persistence_service]
|
807
892
|
end
|
893
|
+
|
894
|
+
#
|
895
|
+
# Convert a symbol to a RiemannType enum value
|
896
|
+
# @param [Symbol] sym the symbol to convert
|
897
|
+
# @return [RiemannType] the RiemannType enum value, or nil if sym is nil
|
898
|
+
#
|
899
|
+
def to_riemann_type(sym)
|
900
|
+
Actions::PersistenceExtensions::RiemannType.value_of(sym.to_s.upcase) if sym
|
901
|
+
end
|
808
902
|
end
|
809
903
|
end
|
810
904
|
end
|
data/lib/openhab/dsl/version.rb
CHANGED
@@ -45,6 +45,9 @@ module OpenHAB
|
|
45
45
|
if match
|
46
46
|
log.warn "In file `#{file}':#{line}: Cannot resolve link to #{name} from text#{match ? ":" : "."}\n" \
|
47
47
|
"\t#{match[1] ? "..." : ""}#{match[2].delete("\n")}#{match[3] ? "..." : ""}"
|
48
|
+
# Don't strip the link. This is so literals like {RUBY_ENGINE_VERSION} remain as they are,
|
49
|
+
# not stripped to "RUBY_ENGINE_VERSION"
|
50
|
+
next str
|
48
51
|
end
|
49
52
|
end
|
50
53
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openhab-scripting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.37.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian O'Connell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
- Jimmy Tanagra
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-03-
|
12
|
+
date: 2025-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|