openhab-scripting 5.8.0 → 5.9.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/things/channel.rb +34 -1
- data/lib/openhab/core/things/proxy.rb +1 -1
- data/lib/openhab/core/things/thing.rb +12 -6
- data/lib/openhab/dsl/things/builder.rb +43 -4
- data/lib/openhab/dsl/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: 6f531c0d4e77bbee531e574b759f56e458d4eacde89520b8cf9f810dd46e61d9
|
|
4
|
+
data.tar.gz: 7724b5709c56fb80f095c14930fd3077a2019111731865f1956f4b080a8039ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11237012154342229a7b1a4b24a2e5e8f81833d758e81614b067c4a1187a598e5fbc45cfd300312ef0f039130a039e6df7c75f59e08e458d0bdf7761e2a85f8d
|
|
7
|
+
data.tar.gz: 3bd394f5d950d2ab5a0016a4219d7d1ac0cb9f4fbdca541d4f41c9e59406c01a1d0df242334cc95a4cf1668f546e1f0fc7aa03cd835f71384e4a3de4cace8304
|
|
@@ -32,9 +32,14 @@ module OpenHAB
|
|
|
32
32
|
def inspect
|
|
33
33
|
r = "#<OpenHAB::Core::Things::Channel #{uid}"
|
|
34
34
|
r += " #{label.inspect}" if label
|
|
35
|
-
r += "
|
|
35
|
+
r += " description=#{description.inspect}" if description
|
|
36
|
+
r += " kind=#{kind.inspect}"
|
|
37
|
+
r += " channel_type_uid=#{channel_type_uid.inspect}" if channel_type_uid
|
|
36
38
|
r += " configuration=#{configuration.properties.to_h}" unless configuration.properties.empty?
|
|
37
39
|
r += " properties=#{properties.to_h}" unless properties.empty?
|
|
40
|
+
r += " default_tags=#{default_tags.to_a}" unless default_tags.empty?
|
|
41
|
+
r += " auto_update_policy=#{auto_update_policy}" if auto_update_policy
|
|
42
|
+
r += " accepted_item_type=#{accepted_item_type}" if accepted_item_type
|
|
38
43
|
"#{r}>"
|
|
39
44
|
end
|
|
40
45
|
|
|
@@ -42,6 +47,34 @@ module OpenHAB
|
|
|
42
47
|
def to_s
|
|
43
48
|
uid.to_s
|
|
44
49
|
end
|
|
50
|
+
|
|
51
|
+
# @deprecated OH3.4 this whole section is not needed in OH4+. Also see Thing#config_eql?
|
|
52
|
+
if Gem::Version.new(Core::VERSION) < Gem::Version.new("4.0.0")
|
|
53
|
+
# @!visibility private
|
|
54
|
+
module ChannelComparable
|
|
55
|
+
# @!visibility private
|
|
56
|
+
# This is only needed in OH3 because it is implemented in OH4 core
|
|
57
|
+
def ==(other)
|
|
58
|
+
return true if equal?(other)
|
|
59
|
+
return false unless other.is_a?(Channel)
|
|
60
|
+
|
|
61
|
+
%i[class
|
|
62
|
+
uid
|
|
63
|
+
label
|
|
64
|
+
description
|
|
65
|
+
kind
|
|
66
|
+
channel_type_uid
|
|
67
|
+
configuration
|
|
68
|
+
properties
|
|
69
|
+
default_tags
|
|
70
|
+
auto_update_policy
|
|
71
|
+
accepted_item_type].all? do |attr|
|
|
72
|
+
send(attr) == other.send(attr)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
org.openhab.core.thing.binding.builder.ChannelBuilder.const_get(:ChannelImpl).prepend(ChannelComparable)
|
|
77
|
+
end
|
|
45
78
|
end
|
|
46
79
|
end
|
|
47
80
|
end
|
|
@@ -64,13 +64,17 @@ module OpenHAB
|
|
|
64
64
|
# Array wrapper class to allow searching a list of channels
|
|
65
65
|
# by channel id
|
|
66
66
|
class ChannelsArray < Array
|
|
67
|
+
def initialize(thing, array)
|
|
68
|
+
super(array)
|
|
69
|
+
@thing = thing
|
|
70
|
+
end
|
|
71
|
+
|
|
67
72
|
# Allows indexing by both integer as an array or channel id acting like a hash.
|
|
68
|
-
# @param [Integer, String] index
|
|
73
|
+
# @param [Integer, String, ChannelUID] index
|
|
74
|
+
# Numeric index, string channel id, or a {ChannelUID} to search for.
|
|
69
75
|
def [](index)
|
|
70
|
-
if index.
|
|
71
|
-
|
|
72
|
-
return find { |channel| channel.uid.id == key }
|
|
73
|
-
end
|
|
76
|
+
return @thing.get_channel(index) if index.is_a?(ChannelUID)
|
|
77
|
+
return @thing.get_channel(index.to_str) if index.respond_to?(:to_str)
|
|
74
78
|
|
|
75
79
|
super
|
|
76
80
|
end
|
|
@@ -204,7 +208,9 @@ module OpenHAB
|
|
|
204
208
|
# @return [true,false] true if all attributes are equal, false otherwise
|
|
205
209
|
#
|
|
206
210
|
def config_eql?(other)
|
|
207
|
-
|
|
211
|
+
# @deprecated OH3.4 - in OH4, channels can be included in the array and do not need to be compared separately
|
|
212
|
+
channels.to_a == other.channels.to_a &&
|
|
213
|
+
%i[uid label bridge_uid location configuration].all? { |method| send(method) == other.send(method) }
|
|
208
214
|
end
|
|
209
215
|
|
|
210
216
|
#
|
|
@@ -257,7 +257,14 @@ module OpenHAB
|
|
|
257
257
|
# The ChannelBuilder DSL allows you to customize a channel
|
|
258
258
|
class ChannelBuilder
|
|
259
259
|
attr_accessor :label
|
|
260
|
-
attr_reader :uid,
|
|
260
|
+
attr_reader :uid,
|
|
261
|
+
:config,
|
|
262
|
+
:type,
|
|
263
|
+
:default_tags,
|
|
264
|
+
:properties,
|
|
265
|
+
:description,
|
|
266
|
+
:auto_update_policy,
|
|
267
|
+
:accepted_item_type
|
|
261
268
|
|
|
262
269
|
#
|
|
263
270
|
# Constructor for ChannelBuilder
|
|
@@ -269,10 +276,27 @@ module OpenHAB
|
|
|
269
276
|
# @param [String] label The channel label.
|
|
270
277
|
# @param [thing] thing The thing associated with this channel.
|
|
271
278
|
# This parameter is not needed for the {ThingBuilder#channel} method.
|
|
279
|
+
# @param [String] description The channel description.
|
|
272
280
|
# @param [String] group The group name.
|
|
273
281
|
# @param [Hash] config Channel configuration. The keys can be strings or symbols.
|
|
282
|
+
# @param [Hash] properties The channel properties.
|
|
283
|
+
# @param [String,Symbol,Semantics::Tag,Array<String,Symbol,Semantics::Tag>] default_tags
|
|
284
|
+
# The default tags for this channel.
|
|
285
|
+
# @param [:default, :recommend, :veto, org.openhab.core.thing.type.AutoUpdatePolicy] auto_update_policy
|
|
286
|
+
# The channel's auto update policy.
|
|
287
|
+
# @param [String] accepted_item_type The accepted item type.
|
|
274
288
|
#
|
|
275
|
-
def initialize(uid,
|
|
289
|
+
def initialize(uid,
|
|
290
|
+
type,
|
|
291
|
+
label = nil,
|
|
292
|
+
thing:,
|
|
293
|
+
description: nil,
|
|
294
|
+
group: nil,
|
|
295
|
+
config: nil,
|
|
296
|
+
properties: nil,
|
|
297
|
+
default_tags: nil,
|
|
298
|
+
auto_update_policy: nil,
|
|
299
|
+
accepted_item_type: nil)
|
|
276
300
|
@thing = thing
|
|
277
301
|
|
|
278
302
|
uid = uid.to_s
|
|
@@ -292,7 +316,14 @@ module OpenHAB
|
|
|
292
316
|
end
|
|
293
317
|
@type = type
|
|
294
318
|
@label = label
|
|
295
|
-
@config = config
|
|
319
|
+
@config = config&.transform_keys(&:to_s)
|
|
320
|
+
@default_tags = Items::ItemBuilder.normalize_tags(*Array.wrap(default_tags))
|
|
321
|
+
@properties = properties&.transform_keys(&:to_s)
|
|
322
|
+
@description = description
|
|
323
|
+
@accepted_item_type = accepted_item_type
|
|
324
|
+
return unless auto_update_policy
|
|
325
|
+
|
|
326
|
+
@auto_update_policy = org.openhab.core.thing.type.AutoUpdatePolicy.value_of(auto_update_policy.to_s.upcase)
|
|
296
327
|
end
|
|
297
328
|
|
|
298
329
|
# @!visibility private
|
|
@@ -300,7 +331,15 @@ module OpenHAB
|
|
|
300
331
|
org.openhab.core.thing.binding.builder.ChannelBuilder.create(uid)
|
|
301
332
|
.with_kind(kind)
|
|
302
333
|
.with_type(type)
|
|
303
|
-
.
|
|
334
|
+
.tap do |builder|
|
|
335
|
+
builder.with_label(label) if label
|
|
336
|
+
builder.with_configuration(Core::Configuration.new(config)) if config && !config.empty?
|
|
337
|
+
builder.with_default_tags(Set.new(default_tags).to_java) unless default_tags.empty?
|
|
338
|
+
builder.with_properties(properties) if properties
|
|
339
|
+
builder.with_description(description) if description
|
|
340
|
+
builder.with_auto_update_policy(auto_update_policy) if auto_update_policy
|
|
341
|
+
builder.with_accepted_item_type(accepted_item_type) if accepted_item_type
|
|
342
|
+
end
|
|
304
343
|
.build
|
|
305
344
|
end
|
|
306
345
|
|
data/lib/openhab/dsl/version.rb
CHANGED
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.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian O'Connell
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2023-10-
|
|
13
|
+
date: 2023-10-09 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: bundler
|