openhab-scripting 5.46.0 → 5.47.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/console/irb.rb +3 -2
- data/lib/openhab/console/stdio.rb +41 -5
- data/lib/openhab/core/items/semantics/semantic_tag.rb +4 -4
- data/lib/openhab/core/items/semantics.rb +1 -1
- data/lib/openhab/dsl/items/builder.rb +12 -9
- data/lib/openhab/dsl/things/builder.rb +4 -7
- 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: 489e56f9a2fe2f2e158736a7a03708b99a26f422f5f3640755d4270b010530fb
|
|
4
|
+
data.tar.gz: 4ccffffac019fd74bda95219dcdd0f126738da018d96f92f4f979a69171c915f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d577c0e485492f29c72662a7ec16d15d2db88851ff194f460d754162290aa173d7304959805ef3bf6295001960d2a3dcc67111a34d6e0e56afea954cc3a5a759
|
|
7
|
+
data.tar.gz: 47093891a302abe04e205584880f000664183ab1cd064a9d7eb145439b4a2bde37f3553520cf9dbf4ee86a68b3388e7d480ddac07b06f122c381bfc13ec2b9a4
|
data/lib/openhab/console/irb.rb
CHANGED
|
@@ -67,6 +67,7 @@ module OpenHAB
|
|
|
67
67
|
|
|
68
68
|
def completion_candidates(_preposing, target, _postposing, bind:)
|
|
69
69
|
return super unless defined?(OpenHAB::Core::EntityLookup)
|
|
70
|
+
return super if target.empty?
|
|
70
71
|
return super unless VALID_ENTITY_PREFIXES.include?(target[0])
|
|
71
72
|
|
|
72
73
|
this = bind.eval("self")
|
|
@@ -88,8 +89,8 @@ module OpenHAB
|
|
|
88
89
|
end
|
|
89
90
|
end
|
|
90
91
|
|
|
91
|
-
# disable Reline
|
|
92
|
-
IRB.conf[:USE_MULTILINE] = false
|
|
92
|
+
# Uncomment to disable Reline and use Readline or StdioInputMethod
|
|
93
|
+
# IRB.conf[:USE_MULTILINE] = false
|
|
93
94
|
# Uncomment to disable Readline and force StdioInputMethod
|
|
94
95
|
# IRB.conf[:USE_SINGLELINE] = false
|
|
95
96
|
|
|
@@ -39,6 +39,11 @@ module OpenHAB
|
|
|
39
39
|
|
|
40
40
|
@byte_stream = terminal.input
|
|
41
41
|
@buffer = StringIO.new.set_encoding(external_encoding)
|
|
42
|
+
@eof = false
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def eof?
|
|
46
|
+
@buffer.eof? && @eof
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
def getbyte
|
|
@@ -47,6 +52,7 @@ module OpenHAB
|
|
|
47
52
|
@buffer.truncate(0) if @buffer.eof?
|
|
48
53
|
return b
|
|
49
54
|
end
|
|
55
|
+
return nil if eof?
|
|
50
56
|
|
|
51
57
|
b = @byte_stream.read
|
|
52
58
|
return nil if b.negative?
|
|
@@ -60,6 +66,8 @@ module OpenHAB
|
|
|
60
66
|
@buffer.truncate(0) if @buffer.eof?
|
|
61
67
|
return c
|
|
62
68
|
end
|
|
69
|
+
return nil if eof?
|
|
70
|
+
|
|
63
71
|
bytes = (+"").force_encoding(Encoding::BINARY)
|
|
64
72
|
loop do
|
|
65
73
|
b = getbyte
|
|
@@ -110,7 +118,9 @@ module OpenHAB
|
|
|
110
118
|
end
|
|
111
119
|
|
|
112
120
|
def read(bytes)
|
|
113
|
-
r = readpartial(bytes)
|
|
121
|
+
r = readpartial(bytes) if !eof? || (@buffer.size - @buffer.tell).positive?
|
|
122
|
+
return nil if r.nil?
|
|
123
|
+
|
|
114
124
|
r.concat(readpartial(bytes - r.bytesize)) while r.bytesize < bytes
|
|
115
125
|
r
|
|
116
126
|
end
|
|
@@ -124,6 +134,8 @@ module OpenHAB
|
|
|
124
134
|
return r
|
|
125
135
|
end
|
|
126
136
|
|
|
137
|
+
raise EOFError, "end of file reached" if eof?
|
|
138
|
+
|
|
127
139
|
buffer = Java::byte[bytes].new
|
|
128
140
|
read = @byte_stream.read_buffered(buffer)
|
|
129
141
|
buffer = buffer[0..read] if read != bytes
|
|
@@ -134,19 +146,43 @@ module OpenHAB
|
|
|
134
146
|
def wait_readable(timeout = nil)
|
|
135
147
|
return true if (@buffer.size - @buffer.tell).positive?
|
|
136
148
|
|
|
137
|
-
|
|
149
|
+
return @byte_stream.available.positive? ? self : nil if timeout == 0 # rubocop:disable Style/NumericPredicate
|
|
150
|
+
|
|
151
|
+
timeout = timeout ? timeout * 1000 : 0
|
|
138
152
|
char = @byte_stream.read(timeout)
|
|
153
|
+
if char == -1
|
|
154
|
+
@eof = true
|
|
155
|
+
# this is not normal behavior for wait_readable, but it seems like when the SSH client
|
|
156
|
+
# disconnects, JLine just "closes" the NonBlockingPumpInputStream, and doesn't trigger
|
|
157
|
+
# any signals. On the other end, Reline just keeps calling this repetitively forever
|
|
158
|
+
# if we're at EOF, with the only way to break out to be check signals. So raise an exception
|
|
159
|
+
# here.
|
|
160
|
+
raise EOFError, "end of file reached"
|
|
161
|
+
end
|
|
139
162
|
return nil if char.negative? # timeout
|
|
140
163
|
|
|
141
164
|
ungetc(char.chr(external_encoding))
|
|
142
165
|
self
|
|
143
166
|
end
|
|
144
167
|
|
|
145
|
-
def raw(
|
|
146
|
-
previous_attributes = @terminal.
|
|
168
|
+
def raw(min: nil, time: nil, intr: nil)
|
|
169
|
+
previous_attributes = @terminal.attributes
|
|
170
|
+
new_attributes = @terminal.attributes
|
|
171
|
+
new_attributes.set_local_flags(java.util.EnumSet.of(org.jline.terminal.Attributes::LocalFlag::ICANON,
|
|
172
|
+
org.jline.terminal.Attributes::LocalFlag::ECHO,
|
|
173
|
+
org.jline.terminal.Attributes::LocalFlag::IEXTEN),
|
|
174
|
+
false)
|
|
175
|
+
new_attributes.set_local_flag(org.jline.terminal.Attributes::LocalFlag::ISIG, !!intr) # rubocop:disable Style/DoubleNegation
|
|
176
|
+
new_attributes.set_input_flags(java.util.EnumSet.of(org.jline.terminal.Attributes::InputFlag::IXON,
|
|
177
|
+
org.jline.terminal.Attributes::InputFlag::ICRNL,
|
|
178
|
+
org.jline.terminal.Attributes::InputFlag::INLCR),
|
|
179
|
+
false)
|
|
180
|
+
new_attributes.set_control_char(org.jline.terminal.Attributes::ControlChar::VMIN, min || 1)
|
|
181
|
+
new_attributes.set_control_char(org.jline.terminal.Attributes::ControlChar::VTIME, ((time || 0) * 10).to_i)
|
|
182
|
+
@terminal.attributes = new_attributes
|
|
147
183
|
yield self
|
|
148
184
|
ensure
|
|
149
|
-
@terminal.set_attributes(previous_attributes)
|
|
185
|
+
@terminal.set_attributes(previous_attributes) if previous_attributes
|
|
150
186
|
end
|
|
151
187
|
end
|
|
152
188
|
|
|
@@ -54,13 +54,13 @@ module OpenHAB
|
|
|
54
54
|
# @!visibility private
|
|
55
55
|
def <(other)
|
|
56
56
|
check_type(other)
|
|
57
|
-
uid
|
|
57
|
+
uid.start_with?("#{other.uid}_")
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
# @!visibility private
|
|
61
61
|
def <=(other)
|
|
62
62
|
check_type(other)
|
|
63
|
-
uid.start_with?(other.uid)
|
|
63
|
+
uid == other.uid || uid.start_with?("#{other.uid}_")
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# @!visibility private
|
|
@@ -72,13 +72,13 @@ module OpenHAB
|
|
|
72
72
|
# @!visibility private
|
|
73
73
|
def >=(other)
|
|
74
74
|
check_type(other)
|
|
75
|
-
other
|
|
75
|
+
other <= self
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
# @!visibility private
|
|
79
79
|
def >(other)
|
|
80
80
|
check_type(other)
|
|
81
|
-
|
|
81
|
+
other < self
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
# @return [String]
|
|
@@ -381,7 +381,7 @@ module OpenHAB
|
|
|
381
381
|
# Property = SemanticTag
|
|
382
382
|
|
|
383
383
|
# put ourself into the global namespace, replacing the action
|
|
384
|
-
Object.send(:remove_const, :Semantics)
|
|
384
|
+
Object.send(:remove_const, :Semantics) if Object.const_defined?(:Semantics)
|
|
385
385
|
::Semantics = self # rubocop:disable Naming/ConstantName
|
|
386
386
|
|
|
387
387
|
#
|
|
@@ -132,18 +132,20 @@ module OpenHAB
|
|
|
132
132
|
|
|
133
133
|
# @!visibility private
|
|
134
134
|
def add(builder)
|
|
135
|
-
if DSL.items
|
|
135
|
+
if (old_item = DSL.items[builder.name])
|
|
136
136
|
raise ArgumentError, "Item #{builder.name} already exists" unless @update
|
|
137
137
|
|
|
138
138
|
# Use provider.get because openHAB's ManagedProvider does not support the #[] method.
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
# Note that ManagedProvider stores PersistableItem objects, not the actual item,
|
|
140
|
+
# so we cannot use provider.get as old_item. We'll get it from the Item Registry instead.
|
|
141
|
+
unless provider.get(builder.name)
|
|
142
|
+
raise FrozenError, "Item #{builder.name} is managed by #{old_item.provider}"
|
|
141
143
|
end
|
|
142
144
|
|
|
143
145
|
item = builder.build
|
|
144
|
-
if item.config_eql?(old_item)
|
|
146
|
+
if item.config_eql?(old_item.__getobj__)
|
|
145
147
|
logger.debug { "Not replacing existing item #{item.uid} because it is identical" }
|
|
146
|
-
item = old_item
|
|
148
|
+
item = old_item.__getobj__
|
|
147
149
|
else
|
|
148
150
|
logger.debug { "Replacing existing item #{item.uid} because it is not identical" }
|
|
149
151
|
provider.update(item)
|
|
@@ -169,6 +171,7 @@ module OpenHAB
|
|
|
169
171
|
if !channel.include?(":") &&
|
|
170
172
|
(thing = builder.thing ||
|
|
171
173
|
thing = builder.groups.find { |g| g.is_a?(GroupItemBuilder) && g.thing }&.thing)
|
|
174
|
+
thing = thing.uid if thing.respond_to?(:uid)
|
|
172
175
|
channel = "#{thing}:#{channel}"
|
|
173
176
|
end
|
|
174
177
|
|
|
@@ -248,7 +251,7 @@ module OpenHAB
|
|
|
248
251
|
# Autoupdate setting
|
|
249
252
|
# @return [true, false, nil]
|
|
250
253
|
attr_accessor :autoupdate
|
|
251
|
-
# @return [String, Core::Things::Thing, Core::Things::ThingUID, nil]
|
|
254
|
+
# @return [String, Core::Things::Thing, Core::Things::ThingUID, DSL::Things::Builder::ThingBuilder, nil]
|
|
252
255
|
# {Core::Things::ThingUID Thing} from which to resolve relative channel ids
|
|
253
256
|
attr_accessor :thing
|
|
254
257
|
# @return [Core::Items::Metadata::NamespaceHash]
|
|
@@ -302,7 +305,7 @@ module OpenHAB
|
|
|
302
305
|
# @param tags [String, Symbol, Semantics::Tag, Array<String, Symbol, Semantics::Tag>, nil]
|
|
303
306
|
# Fluent alias for `tag`.
|
|
304
307
|
# @param autoupdate [true, false, nil] Autoupdate setting (see {ItemBuilder#autoupdate})
|
|
305
|
-
# @param thing [String, Core::Things::Thing, Core::Things::ThingUID, nil]
|
|
308
|
+
# @param thing [String, Core::Things::Thing, Core::Things::ThingUID, DSL::Things::Builder::ThingBuilder, nil]
|
|
306
309
|
# A Thing to be used as the base for the channel.
|
|
307
310
|
# @param channel [String, Symbol, Core::Things::ChannelUID, Core::Things::Channel, nil]
|
|
308
311
|
# Channel to link the item to (see {ItemBuilder#channel}).
|
|
@@ -786,7 +789,7 @@ module OpenHAB
|
|
|
786
789
|
# @return [String, nil]
|
|
787
790
|
attr_accessor :function
|
|
788
791
|
# A thing to be used as the base for the channel of any member items
|
|
789
|
-
# @return [Core::Things::ThingUID, Core::Things::Thing, String, nil]
|
|
792
|
+
# @return [Core::Things::ThingUID, Core::Things::Thing, DSL::Things::Builder::ThingBuilder, String, nil]
|
|
790
793
|
attr_accessor :thing
|
|
791
794
|
# A prefix to be added to the name of any member items
|
|
792
795
|
# @return [String, nil]
|
|
@@ -800,7 +803,7 @@ module OpenHAB
|
|
|
800
803
|
|
|
801
804
|
# @param type [Symbol, nil] The base type for the group
|
|
802
805
|
# @param function [String, nil] The combiner function for this group
|
|
803
|
-
# @param thing [Core::Things::ThingUID, Core::Things::Thing, String, nil]
|
|
806
|
+
# @param thing [Core::Things::ThingUID, Core::Things::Thing, DSL::Things::Builder::ThingBuilder, String, nil]
|
|
804
807
|
# A Thing to be used as the base for the channel for any contained items.
|
|
805
808
|
# @param (see ItemBuilder#initialize)
|
|
806
809
|
def initialize(*, type: nil, function: nil, thing: nil, **)
|
|
@@ -95,16 +95,13 @@ module OpenHAB
|
|
|
95
95
|
builder.instance_eval(&block) if block
|
|
96
96
|
thing = builder.build
|
|
97
97
|
|
|
98
|
-
if DSL.things
|
|
98
|
+
if (old_thing = DSL.things[thing.uid])
|
|
99
99
|
raise ArgumentError, "Thing #{thing.uid} already exists" unless @update
|
|
100
|
+
raise FrozenError, "Thing #{thing.uid} is managed by #{thing.provider}" unless provider.get(thing.uid)
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
raise FrozenError, "Thing #{thing.uid} is managed by #{thing.provider}"
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
if thing.config_eql?(old_thing)
|
|
102
|
+
if thing.config_eql?(old_thing.__getobj__)
|
|
106
103
|
logger.debug { "Not replacing existing thing #{thing.uid}" }
|
|
107
|
-
thing = old_thing
|
|
104
|
+
thing = old_thing.__getobj__
|
|
108
105
|
else
|
|
109
106
|
provider.update(thing)
|
|
110
107
|
end
|
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.47.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian O'Connell
|
|
@@ -354,7 +354,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
354
354
|
- !ruby/object:Gem::Version
|
|
355
355
|
version: '0'
|
|
356
356
|
requirements: []
|
|
357
|
-
rubygems_version: 4.0.
|
|
357
|
+
rubygems_version: 4.0.4
|
|
358
358
|
specification_version: 4
|
|
359
359
|
summary: JRuby Helper Libraries for openHAB Scripting
|
|
360
360
|
test_files: []
|