rspec-openhab-scripting 0.0.9-java → 0.0.10-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec/openhab/dsl/imports.rb +18 -0
- data/lib/rspec/openhab/items.rb +10 -9
- data/lib/rspec/openhab/version.rb +1 -1
- data/lib/rspec-openhab-scripting.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec06e2cfb8832f84f5bd953e22904dbf99ec22a97e5ba0b900ee0e09a163a566
|
4
|
+
data.tar.gz: 959d078c55a2147e8b1899a8efabc6e8d8065fa9c869cda1c1d5ff057784de3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d806b85fd33ce2c42b09f5442bd7dc752327a21c1aae8df5fa57b615dd4935a96c62274ffab8d5dcad9bc94fe034c3073d0af20221cd59e647e00568ae7acc64
|
7
|
+
data.tar.gz: a2565829aa4ddd62cdd1e3ac34e23f55ec9794dcbdeac806bb7175c546f2dcca483cddd72116b1f7726d249c983b7407939de8906e0ec442320d2f2b7b515947
|
@@ -157,6 +157,8 @@ module OpenHAB
|
|
157
157
|
OpenHAB::Core::OSGI.register_service("org.openhab.core.items.MetadataRegistry", mr)
|
158
158
|
mr.managed_provider = mmp = org.openhab.core.internal.items.ManagedMetadataProviderImpl.new(ss)
|
159
159
|
mr.add_provider(mmp)
|
160
|
+
gmp = org.openhab.core.model.item.internal.GenericMetadataProvider.new
|
161
|
+
mr.add_provider(gmp)
|
160
162
|
ir = org.openhab.core.internal.items.ItemRegistryImpl.new(mr)
|
161
163
|
ir.managed_provider = mip = org.openhab.core.items.ManagedItemProvider.new(ss, nil)
|
162
164
|
ir.add_provider(mip)
|
@@ -171,6 +173,22 @@ module OpenHAB
|
|
171
173
|
rr.managed_provider = mrp = org.openhab.core.automation.ManagedRuleProvider.new(ss)
|
172
174
|
rr.add_provider(mrp)
|
173
175
|
iclr = org.openhab.core.thing.link.ItemChannelLinkRegistry.new(tr, ir)
|
176
|
+
ctr = org.openhab.core.thing.type.ChannelTypeRegistry.new
|
177
|
+
ttr = org.openhab.core.thing.type.ThingTypeRegistry.new(ctr)
|
178
|
+
|
179
|
+
safe_emf = org.openhab.core.model.core.internal.SafeEMFImpl.new
|
180
|
+
model_repository = org.openhab.core.model.core.internal.ModelRepositoryImpl.new(safe_emf)
|
181
|
+
|
182
|
+
# set up state descriptions
|
183
|
+
sds = org.openhab.core.internal.service.StateDescriptionServiceImpl.new
|
184
|
+
gip = org.openhab.core.model.item.internal.GenericItemProvider.new(model_repository, gmp, {})
|
185
|
+
sds.add_state_description_fragment_provider(gip)
|
186
|
+
msdfp = org.openhab.core.internal.items.MetadataStateDescriptionFragmentProvider.new(mr, {})
|
187
|
+
sds.add_state_description_fragment_provider(msdfp)
|
188
|
+
csdp = org.openhab.core.thing.internal.ChannelStateDescriptionProvider.new(iclr, ttr, tr)
|
189
|
+
csdp.activate(org.osgi.framework.Constants::SERVICE_RANKING => java.lang.Integer.new(-1))
|
190
|
+
sds.add_state_description_fragment_provider(csdp)
|
191
|
+
ir.state_description_service = sds
|
174
192
|
|
175
193
|
# set up stuff accessed from rules
|
176
194
|
preset = org.openhab.core.automation.module.script.internal.defaultscope
|
data/lib/rspec/openhab/items.rb
CHANGED
@@ -8,25 +8,24 @@ module RSpec
|
|
8
8
|
all_items = api.items
|
9
9
|
|
10
10
|
gfh = org.openhab.core.internal.items.GroupFunctionHelper.new
|
11
|
+
item_factory = org.openhab.core.library.CoreItemFactory.new
|
11
12
|
|
12
13
|
all_items.each do |item_json|
|
13
|
-
|
14
|
+
full_type = item_json["type"]
|
15
|
+
name = item_json["name"]
|
16
|
+
|
17
|
+
type, _dimension = full_type.split(":")
|
14
18
|
if type == "Group"
|
15
|
-
if item_json["groupType"]
|
16
|
-
type, _dimension = item_json["groupType"].split(":")
|
17
|
-
klass = ::OpenHAB::DSL::Items.const_get(:"#{type}Item")
|
18
|
-
base_item = klass.new(item_json["name"])
|
19
|
-
end
|
19
|
+
base_item = item_factory.create_item(item_json["groupType"], name) if item_json["groupType"]
|
20
20
|
if item_json["function"]
|
21
21
|
dto = org.openhab.core.items.dto.GroupFunctionDTO.new
|
22
22
|
dto.name = item_json.dig("function", "name")
|
23
23
|
dto.params = item_json.dig("function", "params")
|
24
24
|
function = gfh.create_group_function(dto, base_item)
|
25
25
|
end
|
26
|
-
item = GroupItem.new(
|
26
|
+
item = GroupItem.new(name, base_item, function)
|
27
27
|
else
|
28
|
-
|
29
|
-
item = klass.new(item_json["name"])
|
28
|
+
item = item_factory.create_item(full_type, name)
|
30
29
|
end
|
31
30
|
|
32
31
|
item.label = item_json["label"]
|
@@ -36,6 +35,8 @@ module RSpec
|
|
36
35
|
item_json["metadata"]&.each do |key, config|
|
37
36
|
item.meta[key] = config["value"], config["config"]
|
38
37
|
end
|
38
|
+
item.meta["stateDescription"] = item_json["stateDescription"] if item_json["stateDescription"]
|
39
|
+
item.category = item_json["category"] if item_json["category"]
|
39
40
|
|
40
41
|
$ir.add(item)
|
41
42
|
end
|
@@ -40,6 +40,7 @@ maven_require do
|
|
40
40
|
require "jar org.openhab.core.bundles, org.openhab.core.config.core, #{openhab_version}"
|
41
41
|
require "jar org.openhab.core.bundles, org.openhab.core.io.monitor, #{openhab_version}"
|
42
42
|
require "jar org.openhab.core.bundles, org.openhab.core.model.core, #{openhab_version}"
|
43
|
+
require "jar org.openhab.core.bundles, org.openhab.core.model.item, #{openhab_version}"
|
43
44
|
require "jar org.openhab.core.bundles, org.openhab.core.model.script, #{openhab_version}"
|
44
45
|
require "jar org.openhab.core.bundles, org.openhab.core.semantics, #{openhab_version}"
|
45
46
|
require "jar org.openhab.core.bundles, org.openhab.core.thing, #{openhab_version}"
|