openhab-scripting 3.8.3 → 3.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openhab/core/entity_lookup.rb +1 -1
- data/lib/openhab/core/load_path.rb +19 -0
- data/lib/openhab/dsl/timers.rb +2 -2
- data/lib/openhab/dsl/types/datetime.rb +3 -3
- data/lib/openhab/version.rb +1 -1
- data/lib/openhab.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c03b915b3027b19b32190a109fd89168ff9d4fd2b636176f7f24b0efc2d39b0
|
4
|
+
data.tar.gz: 281990d13b27ef66090ba90f0413f1102ea3945fc4d8f356688ac38b663ea3c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8531c1602708c55a29159ed8a82193040db66a21a23badeccf3eb960a6ac96dee573716de5e15f1d9b47d95bb4f563be87d54abf7ca7db17c30a104e954e295b
|
7
|
+
data.tar.gz: d880407cc64add80e583f99ba7b8220741b51894ab3479f2dafb63a7a30d9c539abaf2c96abacaa2cfbc8c8f64f6ad6679cc5f470fdeed12973af98eee65761c
|
@@ -129,7 +129,7 @@ module OpenHAB
|
|
129
129
|
# Thing UIDs have at least 3 segements
|
130
130
|
return if name.count('_') < 3
|
131
131
|
|
132
|
-
name = name.
|
132
|
+
name = name.tr('_', ':')
|
133
133
|
# rubocop: disable Style/GlobalVars
|
134
134
|
$things.get(Java::OrgOpenhabCoreThing::ThingUID.new(name))
|
135
135
|
# rubocop: enable Style/GlobalVars
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OpenHAB
|
4
|
+
#
|
5
|
+
# Core support for OpenHAB JRuby Library
|
6
|
+
#
|
7
|
+
module Core
|
8
|
+
#
|
9
|
+
# JRuby isn't respecting $RUBYLIB when run embedded inside of OpenHAB, so do it manually
|
10
|
+
#
|
11
|
+
def self.add_rubylib_to_load_path
|
12
|
+
ENV['RUBYLIB']&.split(File::PATH_SEPARATOR)&.each do |path|
|
13
|
+
next if path.empty?
|
14
|
+
|
15
|
+
$LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/openhab/dsl/timers.rb
CHANGED
@@ -31,14 +31,14 @@ module OpenHAB
|
|
31
31
|
# @param [Duration] duration Duration until timer should fire
|
32
32
|
# @param [Block] block Block to execute when timer fires
|
33
33
|
#
|
34
|
-
def initialize(duration
|
34
|
+
def initialize(duration:)
|
35
35
|
@duration = duration
|
36
36
|
|
37
37
|
# A semaphore is used to prevent a race condition in which calling the block from the timer thread
|
38
38
|
# occurs before the @timer variable can be set resulting in @timer being nil
|
39
39
|
semaphore = Mutex.new
|
40
40
|
|
41
|
-
timer_block = proc { semaphore.synchronize {
|
41
|
+
timer_block = proc { semaphore.synchronize { yield(self) } }
|
42
42
|
|
43
43
|
semaphore.synchronize do
|
44
44
|
@timer = ScriptExecution.createTimer(
|
@@ -81,7 +81,7 @@ module OpenHAB
|
|
81
81
|
|
82
82
|
case other
|
83
83
|
when TimeOfDay::TimeOfDay, TimeOfDay::TimeOfDayRangeElement then to_tod <=> other
|
84
|
-
when String then self <=> DateTime.parse(DATE_ONLY_REGEX
|
84
|
+
when String then self <=> DateTime.parse(DATE_ONLY_REGEX.match?(other) ? "#{other}'T'00:00:00#{zone}" : other)
|
85
85
|
else
|
86
86
|
self <=> DateTime.from(other)
|
87
87
|
end
|
@@ -120,7 +120,7 @@ module OpenHAB
|
|
120
120
|
when Numeric then DateTime.from(to_time - other)
|
121
121
|
when String
|
122
122
|
dt = DateTime.parse(other)
|
123
|
-
TIME_ONLY_REGEX
|
123
|
+
TIME_ONLY_REGEX.match?(other) ? self - dt.to_f : time_diff(dt)
|
124
124
|
when Duration then DateTime.new(zoned_date_time.minus(other))
|
125
125
|
when Time, DateTime, DateTimeType, DateTimeItem then time_diff(other)
|
126
126
|
end
|
@@ -298,7 +298,7 @@ module OpenHAB
|
|
298
298
|
# @return [Java::org::openhab::core::library::types::DateTimeType] Object representing the same time
|
299
299
|
#
|
300
300
|
def self.parse(time_string)
|
301
|
-
time_string += 'Z' if TIME_ONLY_REGEX
|
301
|
+
time_string += 'Z' if TIME_ONLY_REGEX.match?(time_string)
|
302
302
|
DateTime.new(DateTimeType.new(time_string))
|
303
303
|
rescue Java::JavaLang::StringIndexOutOfBoundsException, Java::JavaLang::IllegalArgumentException
|
304
304
|
# Try ruby's Time.parse if OpenHAB's DateTimeType parser fails
|
data/lib/openhab/version.rb
CHANGED
data/lib/openhab.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'openhab/core/load_path'
|
3
4
|
require 'openhab/core/openhab_setup'
|
4
5
|
require 'openhab/log/logger'
|
5
6
|
require 'openhab/dsl/dsl'
|
@@ -28,6 +29,8 @@ module OpenHAB
|
|
28
29
|
base.send :include, OpenHAB::DSL::Items
|
29
30
|
base.send :include, OpenHAB::DSL::Types
|
30
31
|
logger.info "OpenHAB JRuby Scripting Library Version #{OpenHAB::VERSION} Loaded"
|
32
|
+
|
33
|
+
OpenHAB::Core.add_rubylib_to_load_path
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openhab-scripting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian O'Connell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -47,6 +47,7 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- lib/openhab.rb
|
49
49
|
- lib/openhab/core/entity_lookup.rb
|
50
|
+
- lib/openhab/core/load_path.rb
|
50
51
|
- lib/openhab/core/openhab_setup.rb
|
51
52
|
- lib/openhab/core/osgi.rb
|
52
53
|
- lib/openhab/dsl/actions.rb
|