openhab-scripting 4.36.0 → 4.37.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openhab/dsl/dsl.rb +4 -0
- data/lib/openhab/dsl/imports.rb +21 -0
- data/lib/openhab/dsl/items/timed_command.rb +1 -0
- data/lib/openhab/dsl/openhab.rb +11 -6
- data/lib/openhab/dsl/rules/automation_rule.rb +1 -1
- data/lib/openhab/dsl/timers/manager.rb +15 -2
- data/lib/openhab/dsl/timers/timer.rb +1 -1
- data/lib/openhab/dsl/types/date_time_type.rb +0 -1
- data/lib/openhab/version.rb +1 -1
- 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: 152174c3766a83b620a0ec7df6e692bb914e187c788d9c5eecfcedd42bfd641c
|
4
|
+
data.tar.gz: 44084d3557abd293faf97858470414cf5f3dd65e07faa8f74e8f40e0d6ea8edb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 617deb9b4f75a92a407cf8db6ff695f409ac5f006690751c10100919d414851dc83758ec0560badf3d40097cc896d86de132a215d22a3f505b8e97bff26a8ad2
|
7
|
+
data.tar.gz: 5a2c037047ce9db79d57a153e5df94c631144d511ac716b1862a8a6c4fc567d01c6efa15d93583f2bc80a792c47c85e30dda65ec481a1f14f6a588765638d56f
|
data/lib/openhab/dsl/dsl.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OpenHAB
|
4
|
+
module DSL
|
5
|
+
include OpenHAB::Log
|
6
|
+
#
|
7
|
+
# Import required java classes
|
8
|
+
#
|
9
|
+
def self.import_presets # rubocop:disable Metrics/AbcSize
|
10
|
+
return if Object.const_get(:ZonedDateTime).is_a?(Class)
|
11
|
+
|
12
|
+
# Fix the import problem in OpenHAB 3.2 addon. Not required in 3.3+
|
13
|
+
[java.time.Duration,
|
14
|
+
java.time.ZonedDateTime,
|
15
|
+
java.time.ZoneId,
|
16
|
+
java.time.temporal.ChronoUnit].each do |klass|
|
17
|
+
Object.const_set(klass.java_class.simple_name.to_sym, klass)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -171,6 +171,7 @@ module OpenHAB
|
|
171
171
|
# rubocop: disable Metrics/AbcSize
|
172
172
|
# There is no feasible way to break this method into smaller components
|
173
173
|
def execute(_mod = nil, inputs = nil)
|
174
|
+
OpenHAB::DSL.import_presets
|
174
175
|
@semaphore.synchronize do
|
175
176
|
thread_local(@thread_locals) do
|
176
177
|
logger.trace "Canceling implicit timer #{@timed_command_details.timer} for "\
|
data/lib/openhab/dsl/openhab.rb
CHANGED
@@ -3,6 +3,15 @@
|
|
3
3
|
require 'pathname'
|
4
4
|
|
5
5
|
module OpenHAB
|
6
|
+
#
|
7
|
+
# Return the OpenHAB conf directory as a ruby pathname
|
8
|
+
#
|
9
|
+
# @return [Pathname] OpenHAB conf path
|
10
|
+
#
|
11
|
+
def self.conf_root
|
12
|
+
Pathname.new(ENV['OPENHAB_CONF'])
|
13
|
+
end
|
14
|
+
|
6
15
|
module DSL
|
7
16
|
#
|
8
17
|
# Provides access to OpenHAB attributes
|
@@ -12,13 +21,9 @@ module OpenHAB
|
|
12
21
|
|
13
22
|
module_function
|
14
23
|
|
15
|
-
#
|
16
|
-
# Return the OpenHAB conf directory as a ruby pathname
|
17
|
-
#
|
18
|
-
# @return [Pathname] OpenHAB conf path
|
19
|
-
#
|
24
|
+
# @deprecated Please use {OpenHAB.conf_root} instead
|
20
25
|
def __conf__
|
21
|
-
|
26
|
+
OpenHAB.conf_root
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
@@ -23,7 +23,6 @@ module OpenHAB
|
|
23
23
|
include OpenHAB::Log
|
24
24
|
include OpenHAB::Core::ThreadLocal
|
25
25
|
include OpenHAB::DSL::Between
|
26
|
-
java_import java.time.ZonedDateTime
|
27
26
|
|
28
27
|
#
|
29
28
|
# Create a new Rule
|
@@ -55,6 +54,7 @@ module OpenHAB
|
|
55
54
|
#
|
56
55
|
#
|
57
56
|
def execute(mod = nil, inputs = nil)
|
57
|
+
OpenHAB::DSL.import_presets
|
58
58
|
thread_local(RULE_NAME: name) do
|
59
59
|
logger.trace { "Execute called with mod (#{mod&.to_string}) and inputs (#{inputs.inspect})" }
|
60
60
|
logger.trace { "Event details #{inputs['event'].inspect}" } if inputs&.key?('event')
|
@@ -95,11 +95,24 @@ module OpenHAB
|
|
95
95
|
class TimerSet < Set
|
96
96
|
#
|
97
97
|
# A shorthand to cancel all the timer objects held within the set
|
98
|
-
# so that timers[timer_id].
|
98
|
+
# so that timers[timer_id].cancel is equivalent to timers[timer_id].each(&:cancel)
|
99
99
|
#
|
100
|
-
def
|
100
|
+
def cancel
|
101
101
|
each(&:cancel)
|
102
102
|
end
|
103
|
+
# @deprecated Please use {cancel} instead
|
104
|
+
alias cancel_all cancel
|
105
|
+
|
106
|
+
#
|
107
|
+
# A shorthand to reschedule all the timer objects held within the set
|
108
|
+
#
|
109
|
+
# @param [Duration] duration An optional duration to reschedule
|
110
|
+
#
|
111
|
+
# @return [TimerSet] Set of timers
|
112
|
+
#
|
113
|
+
def reschedule(duration = nil)
|
114
|
+
each { |timer| timer.reschedule duration }
|
115
|
+
end
|
103
116
|
end
|
104
117
|
end
|
105
118
|
end
|
@@ -9,7 +9,6 @@ require 'openhab/core/thread_local'
|
|
9
9
|
module OpenHAB
|
10
10
|
module DSL
|
11
11
|
java_import org.openhab.core.model.script.actions.ScriptExecution
|
12
|
-
java_import java.time.ZonedDateTime
|
13
12
|
|
14
13
|
# Ruby wrapper for OpenHAB Timer
|
15
14
|
# This class implements delegator to delegate methods to the OpenHAB timer
|
@@ -80,6 +79,7 @@ module OpenHAB
|
|
80
79
|
#
|
81
80
|
def timer_block(semaphore)
|
82
81
|
proc {
|
82
|
+
OpenHAB::DSL.import_presets
|
83
83
|
semaphore.synchronize do
|
84
84
|
Timers.timer_manager.delete(self)
|
85
85
|
thread_local(@thread_locals) do
|
@@ -8,7 +8,6 @@ module OpenHAB
|
|
8
8
|
module DSL
|
9
9
|
module Types
|
10
10
|
DateTimeType = org.openhab.core.library.types.DateTimeType
|
11
|
-
java_import java.time.ZonedDateTime # This is needed for the addon prior to ruby_class fix (OH 3.2.0)
|
12
11
|
|
13
12
|
# global alias - required for jrubyscripting addon <= OH3.2.0
|
14
13
|
::DateTimeType = DateTimeType if ::DateTimeType.is_a?(Java::JavaLang::Class)
|
data/lib/openhab/version.rb
CHANGED
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: 4.
|
4
|
+
version: 4.37.0
|
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: 2022-04-
|
11
|
+
date: 2022-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/openhab/dsl/dsl.rb
|
61
61
|
- lib/openhab/dsl/gems.rb
|
62
62
|
- lib/openhab/dsl/group.rb
|
63
|
+
- lib/openhab/dsl/imports.rb
|
63
64
|
- lib/openhab/dsl/items/color_item.rb
|
64
65
|
- lib/openhab/dsl/items/comparable_item.rb
|
65
66
|
- lib/openhab/dsl/items/contact_item.rb
|