openhab-scripting 5.44.1 → 5.45.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/actions/transformation.rb +1 -1
- data/lib/openhab/core/actions/voice.rb +1 -1
- data/lib/openhab/core/gem.rb +17 -0
- data/lib/openhab/core/items.rb +5 -5
- data/lib/openhab/core/lazy_array.rb +2 -2
- data/lib/openhab/core/types/date_time_type.rb +2 -2
- data/lib/openhab/core/types.rb +29 -29
- data/lib/openhab/core.rb +7 -1
- data/lib/openhab/core_ext/java/duration.rb +1 -1
- data/lib/openhab/core_ext/ruby/symbol.rb +1 -1
- data/lib/openhab/dsl/config_description/builder.rb +24 -20
- data/lib/openhab/dsl/items/builder.rb +1 -1
- data/lib/openhab/dsl/version.rb +1 -1
- data/lib/openhab/rspec/helpers.rb +11 -11
- data/lib/openhab/rspec/karaf.rb +2 -1
- metadata +22 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a6ff4c8c427bbcf314fb2226da8fcc4791ee9395394f404e88567a4417e1b4f
|
|
4
|
+
data.tar.gz: 254980e2b97d5cd3f3c44990ed5e1cd84e0c31d2a8a9490146d317e0c2f3d9a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 01b946e0402acf49358f2de450960fd716f654c668bd40f419a5c768672d2bd7272fa89d5bef1c0e7f61f57968156c2a9d9b2a47b01b0e6065432962df568a12
|
|
7
|
+
data.tar.gz: 6ef1bc5b35034eac211a4024586e04d27c8aeeba8f2e7d21ab6999ba32b6d72c567a29c81010b559685af51d2bd69d461ea32726149c044fe090a8aa757fd09f
|
|
@@ -7,7 +7,7 @@ module OpenHAB
|
|
|
7
7
|
class Transformation
|
|
8
8
|
class << self
|
|
9
9
|
# @!visibility private
|
|
10
|
-
alias_method :raw_transform, :transform if
|
|
10
|
+
alias_method :raw_transform, :transform if method_defined?(:transform)
|
|
11
11
|
|
|
12
12
|
#
|
|
13
13
|
# Applies a transformation of a given type with some function to a value.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
openhab_spec = Gem::Specification.new do |s|
|
|
4
|
+
s.name = "openhab"
|
|
5
|
+
s.version = -(ENV["OPENHAB_VERSION"] || "5.1.0")
|
|
6
|
+
|
|
7
|
+
def s.deleted_gem?
|
|
8
|
+
false
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def s.installation_missing?
|
|
12
|
+
false
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Gem::Specification.add_spec(openhab_spec)
|
|
17
|
+
Gem.post_reset { Gem::Specification.add_spec(openhab_spec) }
|
data/lib/openhab/core/items.rb
CHANGED
|
@@ -42,7 +42,7 @@ module OpenHAB
|
|
|
42
42
|
def def_predicate_methods(klass)
|
|
43
43
|
values_for_enums(klass.ACCEPTED_DATA_TYPES).each do |state|
|
|
44
44
|
_command_predicate, state_predicate = Types::PREDICATE_ALIASES[state.to_s]
|
|
45
|
-
next if klass.
|
|
45
|
+
next if klass.method_defined?(state_predicate)
|
|
46
46
|
|
|
47
47
|
logger.trace { "Defining #{klass}##{state_predicate} for #{state}" }
|
|
48
48
|
klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
|
@@ -62,7 +62,7 @@ module OpenHAB
|
|
|
62
62
|
def def_command_methods(klass)
|
|
63
63
|
values_for_enums(klass.ACCEPTED_COMMAND_TYPES).each do |value|
|
|
64
64
|
command = Types::COMMAND_ALIASES[value.to_s]
|
|
65
|
-
next if klass.
|
|
65
|
+
next if klass.method_defined?(command)
|
|
66
66
|
|
|
67
67
|
if value.is_a?(Types::State)
|
|
68
68
|
logger.trace { "Defining #{klass}/Enumerable##{command}/#{command}! for #{value}" }
|
|
@@ -128,10 +128,10 @@ module OpenHAB
|
|
|
128
128
|
.select { |k| k <= GenericItem && k != GroupItem && k != StringItem }
|
|
129
129
|
.sort { |a, b| (a < b) ? 1 : -1 }
|
|
130
130
|
.each do |klass|
|
|
131
|
-
|
|
131
|
+
klass.field_reader :ACCEPTED_COMMAND_TYPES, :ACCEPTED_DATA_TYPES unless klass == GenericItem
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
def_predicate_methods(klass)
|
|
134
|
+
def_command_methods(klass)
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
prepend_accepted_data_types
|
|
@@ -36,14 +36,14 @@ module OpenHAB
|
|
|
36
36
|
|
|
37
37
|
# Delegate any other methods to the actual array, exclude mutating methods
|
|
38
38
|
def method_missing(method, ...)
|
|
39
|
-
return to_a.send(method, ...) if method[-1] != "!" && Array.
|
|
39
|
+
return to_a.send(method, ...) if method[-1] != "!" && Array.method_defined?(method)
|
|
40
40
|
|
|
41
41
|
super
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# @!visibility private
|
|
45
45
|
def respond_to_missing?(method, include_private = false)
|
|
46
|
-
return true if method[-1] != "!" && Array.
|
|
46
|
+
return true if method[-1] != "!" && Array.method_defined?(method.to_sym)
|
|
47
47
|
|
|
48
48
|
super
|
|
49
49
|
end
|
|
@@ -225,7 +225,7 @@ module OpenHAB
|
|
|
225
225
|
# @deprecated OH 4.2 Remove version check when dropping OH 4.2
|
|
226
226
|
return true if OpenHAB::Core.version >= OpenHAB::Core::V4_3 && to_instant.respond_to?(method)
|
|
227
227
|
return true if zoned_date_time.respond_to?(method)
|
|
228
|
-
return true if ::Time.
|
|
228
|
+
return true if ::Time.method_defined?(method.to_sym)
|
|
229
229
|
|
|
230
230
|
super
|
|
231
231
|
end
|
|
@@ -241,7 +241,7 @@ module OpenHAB
|
|
|
241
241
|
end
|
|
242
242
|
|
|
243
243
|
return zoned_date_time.send(method, ...) if zoned_date_time.respond_to?(method)
|
|
244
|
-
return to_time.send(method, ...) if ::Time.
|
|
244
|
+
return to_time.send(method, ...) if ::Time.method_defined?(method.to_sym)
|
|
245
245
|
|
|
246
246
|
super
|
|
247
247
|
end
|
data/lib/openhab/core/types.rb
CHANGED
|
@@ -43,39 +43,39 @@ module OpenHAB
|
|
|
43
43
|
.grep(Module)
|
|
44
44
|
.select { |k| k < java.lang.Enum }
|
|
45
45
|
.each do |klass|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
# make sure == from Type is inherited
|
|
47
|
+
klass.remove_method(:==)
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
# dynamically define predicate methods
|
|
50
|
+
klass.values.each do |value| # rubocop:disable Style/HashEachMethods -- this isn't a Ruby hash
|
|
51
|
+
# include all the aliases that we define for items both command and
|
|
52
|
+
# state aliases (since types can be interrogated as an incoming
|
|
53
|
+
# command, or as the state of an item)
|
|
54
|
+
command = :"#{Types::COMMAND_ALIASES[value.to_s]}?"
|
|
55
|
+
states = Types::PREDICATE_ALIASES[value.to_s]
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
([command] | states).each do |method|
|
|
58
|
+
logger.trace { "Defining #{klass}##{method} for #{value}" }
|
|
59
|
+
klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
|
60
|
+
def #{method} # def on?
|
|
61
|
+
as(#{value.class.java_class.simple_name}).equal?(#{value}) # as(OnOffType).equal?(ON)
|
|
62
|
+
end # end
|
|
63
|
+
RUBY
|
|
64
|
+
end
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
method = states.last
|
|
67
|
+
Events::ItemState.class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
|
68
|
+
def #{method} # def on?
|
|
69
|
+
item_state.as(#{value.class.java_class.simple_name}).equal?(#{value}) # item_state.as(OnOffType).equal?(ON)
|
|
70
|
+
end # end
|
|
71
|
+
RUBY
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
Events::ItemStateChangedEvent.class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
|
74
|
+
def was_#{method} # def was_on?
|
|
75
|
+
old_item_state.as(#{value.class.java_class.simple_name}).equal?(#{value}) # old_item_state.as(OnOffType).equal?(ON)
|
|
76
|
+
end # end
|
|
77
|
+
RUBY
|
|
78
|
+
end
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
end
|
data/lib/openhab/core.rb
CHANGED
|
@@ -17,6 +17,8 @@ module OpenHAB
|
|
|
17
17
|
V5_0 = Gem::Version.new("5.0.0").freeze
|
|
18
18
|
# @!visibility private
|
|
19
19
|
V5_1 = Gem::Version.new("5.1.0").freeze
|
|
20
|
+
# @!visibility private
|
|
21
|
+
V5_2 = Gem::Version.new("5.2.0").freeze
|
|
20
22
|
|
|
21
23
|
# @return [Gem::Version] Returns the current openHAB version as a Gem::Version object
|
|
22
24
|
# Note, this strips off snapshots, milestones and RC versions and returns the release version.
|
|
@@ -159,6 +161,10 @@ end
|
|
|
159
161
|
require_relative "core/provider"
|
|
160
162
|
|
|
161
163
|
Dir[File.expand_path("core/**/*.rb", __dir__)].each do |f|
|
|
164
|
+
# already been run by either a binstub, or the addon
|
|
165
|
+
next if f.end_with?("gem.rb")
|
|
162
166
|
# metadata is autoloaded
|
|
163
|
-
|
|
167
|
+
next if f.include?("/metadata/")
|
|
168
|
+
|
|
169
|
+
require f
|
|
164
170
|
end
|
|
@@ -36,7 +36,7 @@ module OpenHAB
|
|
|
36
36
|
# @return [true,false] Returns true if the duration is less than zero.
|
|
37
37
|
#
|
|
38
38
|
|
|
39
|
-
unless
|
|
39
|
+
unless method_defined?(:positive?)
|
|
40
40
|
#
|
|
41
41
|
# @return [true, false] Returns true if the duration is greater than zero.
|
|
42
42
|
#
|
|
@@ -106,29 +106,33 @@ module OpenHAB
|
|
|
106
106
|
unit_label: nil,
|
|
107
107
|
verify: false)
|
|
108
108
|
# Extract the named arguments into a hash
|
|
109
|
-
@parameters <<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
109
|
+
@parameters <<
|
|
110
|
+
method(__method__)
|
|
111
|
+
.parameters
|
|
112
|
+
.select { |param_type, _| param_type == :key } # rubocop:disable Style/HashSlice
|
|
113
|
+
.to_h { |_, key| [key, binding.local_variable_get(key)] }
|
|
114
|
+
.then do |p|
|
|
115
|
+
p[:options] = p[:options].map do |opt_value, opt_label|
|
|
116
|
+
org.openhab.core.config.core.ParameterOption.new(opt_value, opt_label)
|
|
117
|
+
end
|
|
118
|
+
p[:filter_criteria] = p[:filter_criteria].map do |filter_name, filter_value|
|
|
119
|
+
org.openhab.core.config.core.FilterCriteria.new(filter_name, filter_value)
|
|
120
|
+
end
|
|
121
|
+
p[:minimum] = p.delete(:min)&.to_d&.to_java
|
|
122
|
+
p[:maximum] = p.delete(:max)&.to_d&.to_java
|
|
123
|
+
p[:step] = p.delete(:step)&.to_d&.to_java
|
|
124
|
+
p[:group_name] ||= @current_group
|
|
125
|
+
type = org.openhab.core.config.core.ConfigDescriptionParameter::Type.value_of(type.to_s.upcase)
|
|
124
126
|
|
|
125
|
-
|
|
127
|
+
parameter = org.openhab.core.config.core.ConfigDescriptionParameterBuilder.create(
|
|
128
|
+
name.to_s, type
|
|
129
|
+
)
|
|
126
130
|
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
p.each do |key, value|
|
|
132
|
+
parameter.send(:"with_#{key}", value) unless value.nil?
|
|
133
|
+
end
|
|
134
|
+
parameter.build
|
|
129
135
|
end
|
|
130
|
-
parameter.build
|
|
131
|
-
end
|
|
132
136
|
end
|
|
133
137
|
|
|
134
138
|
#
|
|
@@ -152,7 +152,7 @@ module OpenHAB
|
|
|
152
152
|
item.metadata
|
|
153
153
|
.reject { |namespace, _| builder.metadata.key?(namespace) }
|
|
154
154
|
.each do |namespace, metadata|
|
|
155
|
-
|
|
155
|
+
item.metadata.delete(namespace) if metadata.provider == Core::Items::Metadata::Provider.current
|
|
156
156
|
end
|
|
157
157
|
else
|
|
158
158
|
item = builder.build
|
data/lib/openhab/dsl/version.rb
CHANGED
|
@@ -201,7 +201,7 @@ module OpenHAB
|
|
|
201
201
|
.split(File::PATH_SEPARATOR)
|
|
202
202
|
.reject(&:empty?)
|
|
203
203
|
.reject do |path|
|
|
204
|
-
|
|
204
|
+
$LOAD_PATH.include?(path)
|
|
205
205
|
end)
|
|
206
206
|
|
|
207
207
|
requires = jrubyscripting_config&.get("require") || ""
|
|
@@ -268,16 +268,16 @@ module OpenHAB
|
|
|
268
268
|
OSGi.service_component_classes(bundle)
|
|
269
269
|
.select { |klass, _services| klass.ancestors.include?(ast.java_class) }
|
|
270
270
|
.each do |klass, services|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
271
|
+
new_ast_klass = Class.new(ast)
|
|
272
|
+
new_ast_klass.become_java!
|
|
273
|
+
wrapped_storage_service = Mocks::AbstractStorageBasedTypeProviderWrappedStorageService
|
|
274
|
+
.new(storage_service,
|
|
275
|
+
new_ast_klass.java_class,
|
|
276
|
+
klass)
|
|
277
|
+
new_ast = new_ast_klass.new(wrapped_storage_service)
|
|
278
|
+
|
|
279
|
+
services -= [klass.name]
|
|
280
|
+
OSGi.register_service(new_ast, *services, bundle: ast_bundle)
|
|
281
281
|
end
|
|
282
282
|
end
|
|
283
283
|
rescue NameError
|
data/lib/openhab/rspec/karaf.rb
CHANGED
|
@@ -786,7 +786,7 @@ module OpenHAB
|
|
|
786
786
|
|
|
787
787
|
<blacklistedFeatures>
|
|
788
788
|
<feature>openhab-runtime-ui</feature>
|
|
789
|
-
<feature>openhab-core-ui
|
|
789
|
+
<feature>openhab-core-ui</feature>
|
|
790
790
|
<feature>openhab-misc-*</feature>
|
|
791
791
|
<feature>openhab-persistence-*</feature>
|
|
792
792
|
<feature>openhab-package-standard</feature>
|
|
@@ -807,6 +807,7 @@ module OpenHAB
|
|
|
807
807
|
<f:feature>openhab-core-model-sitemap</f:feature>
|
|
808
808
|
<f:feature>openhab-core-model-thing</f:feature>
|
|
809
809
|
<f:feature>openhab-core-storage-json</f:feature>
|
|
810
|
+
<f:feature>openhab-core-ui-icon</f:feature>
|
|
810
811
|
<f:feature>openhab-transport-http</f:feature>
|
|
811
812
|
<f:feature prerequisite="true">wrapper</f:feature>
|
|
812
813
|
<f:bundle>mvn:org.openhab.core.bundles/org.openhab.core.karaf/#{version}</f:bundle>
|
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.45.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian O'Connell
|
|
@@ -53,6 +53,26 @@ dependencies:
|
|
|
53
53
|
- - "~>"
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
55
|
version: '1.0'
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: openhab
|
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: 4.1.0
|
|
63
|
+
- - "<"
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '5.3'
|
|
66
|
+
type: :runtime
|
|
67
|
+
prerelease: false
|
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
69
|
+
requirements:
|
|
70
|
+
- - ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: 4.1.0
|
|
73
|
+
- - "<"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '5.3'
|
|
56
76
|
email:
|
|
57
77
|
- broconne+github@gmail.com
|
|
58
78
|
- cody@cutrer.us
|
|
@@ -100,6 +120,7 @@ files:
|
|
|
100
120
|
- lib/openhab/core/events/startlevel_event.rb
|
|
101
121
|
- lib/openhab/core/events/thing_status_info_event.rb
|
|
102
122
|
- lib/openhab/core/events/timer_event.rb
|
|
123
|
+
- lib/openhab/core/gem.rb
|
|
103
124
|
- lib/openhab/core/items.rb
|
|
104
125
|
- lib/openhab/core/items/accepted_data_types.rb
|
|
105
126
|
- lib/openhab/core/items/call_item.rb
|