openhab-scripting 4.45.2 → 4.46.2
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/items/ensure.rb +3 -2
- data/lib/openhab/dsl/items/timed_command.rb +1 -1
- data/lib/openhab/dsl/openhab.rb +1 -1
- data/lib/openhab/dsl/rules/automation_rule.rb +1 -1
- data/lib/openhab/dsl/rules/triggers/changed.rb +1 -1
- data/lib/openhab/dsl/rules/triggers/conditions/duration.rb +1 -1
- data/lib/openhab/dsl/time/month_day.rb +8 -12
- data/lib/openhab/dsl/time/time_of_day.rb +3 -3
- data/lib/openhab/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58e9795c07e518f1c4a287e74e8421344775e0d35d837929e3eec4f3c04b1976
|
4
|
+
data.tar.gz: de241ff22e0654edefd70e7cdc6c9acaaf67bb57356977f7ce6b95cefb49d0e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 776dbaf7ee8766135b9199ebc94792982780bc1ce1143093187afdf1223ddcbc814a328ab1ba025fe5d2d79bfd0cb42322f7228c3472cb15c6614ee1028519c5
|
7
|
+
data.tar.gz: 1713aac4bc54977d347d7e8edf13cf03f9a5ff3600b63c1cea816c8d3717dcb1c52c72a215d2fe895fe2b1ca01181cbde4afd3b7e0c36e052735a48df4fff946
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'ruby2_keywords'
|
4
|
+
require 'openhab/log/logger'
|
3
5
|
require_relative 'generic_item'
|
4
6
|
|
5
7
|
module OpenHAB
|
@@ -81,14 +83,13 @@ module OpenHAB
|
|
81
83
|
end
|
82
84
|
|
83
85
|
# activate +ensure_states+ before forwarding to the wrapped object
|
84
|
-
def method_missing(method, *args, &block)
|
86
|
+
ruby2_keywords def method_missing(method, *args, &block)
|
85
87
|
return super unless @item.respond_to?(method)
|
86
88
|
|
87
89
|
ensure_states do
|
88
90
|
@item.__send__(method, *args, &block)
|
89
91
|
end
|
90
92
|
end
|
91
|
-
ruby2_keywords :method_missing if respond_to? :ruby2_keywords
|
92
93
|
|
93
94
|
# .
|
94
95
|
def respond_to_missing?(method, include_private = false)
|
@@ -174,7 +174,7 @@ module OpenHAB
|
|
174
174
|
OpenHAB::DSL.import_presets
|
175
175
|
@semaphore.synchronize do
|
176
176
|
thread_local(**@thread_locals) do
|
177
|
-
logger.trace "Canceling implicit timer #{@timed_command_details.timer} for "\
|
177
|
+
logger.trace "Canceling implicit timer #{@timed_command_details.timer} for " \
|
178
178
|
"#{@timed_command_details.item.id} because received event #{inputs}"
|
179
179
|
@timed_command_details.timer.cancel
|
180
180
|
# Disabled due to OpenHAB design
|
data/lib/openhab/dsl/openhab.rb
CHANGED
@@ -162,7 +162,7 @@ module OpenHAB
|
|
162
162
|
now = Time.now
|
163
163
|
return true if @between.cover? now
|
164
164
|
|
165
|
-
logger.trace("Skipped execution of rule '#{name}' because the current time #{now} "\
|
165
|
+
logger.trace("Skipped execution of rule '#{name}' because the current time #{now} " \
|
166
166
|
"is not between #{@between.begin} and #{@between.end}")
|
167
167
|
else
|
168
168
|
logger.trace("Skipped execution of rule '#{name}' because of guard #{@guard}")
|
@@ -112,7 +112,7 @@ module OpenHAB
|
|
112
112
|
#
|
113
113
|
def wait_trigger(item:, duration:, to: nil, from: nil, attach: nil)
|
114
114
|
item_name = item.respond_to?(:name) ? item.name : item.to_s
|
115
|
-
logger.trace("Creating Changed Wait Change Trigger for Item(#{item_name}) Duration(#{duration}) "\
|
115
|
+
logger.trace("Creating Changed Wait Change Trigger for Item(#{item_name}) Duration(#{duration}) " \
|
116
116
|
"To(#{to}) From(#{from}) Attach(#{attach})")
|
117
117
|
conditions = Conditions::Duration.new(to: to, from: from, duration: duration)
|
118
118
|
changed_trigger(item: item, to: nil, from: nil, attach: attach, conditions: conditions)
|
@@ -36,7 +36,7 @@ module OpenHAB
|
|
36
36
|
@conditions = Conditions::Proc.new(to: to, from: from)
|
37
37
|
@duration = duration
|
38
38
|
@timer = nil
|
39
|
-
logger.trace "Created Duration Condition To(#{to}) From(#{from}) "\
|
39
|
+
logger.trace "Created Duration Condition To(#{to}) From(#{from}) " \
|
40
40
|
"Conditions(#{@conditions}) Duration(#{@duration})"
|
41
41
|
end
|
42
42
|
|
@@ -102,16 +102,6 @@ module OpenHAB
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
java_import java.time.Month
|
106
|
-
# Extend Month with helper method
|
107
|
-
class Month
|
108
|
-
# Calcalute and memoize the maximum number of days in a year before this month
|
109
|
-
# @return [Number] maximum nummber of days in a year before this month
|
110
|
-
def max_days_before
|
111
|
-
@max_days_before ||= Month.values.select { |month| month < self }.sum(&:max_length)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
105
|
java_import java.time.MonthDay
|
116
106
|
# Extend MonthDay java object with some helper methods
|
117
107
|
class MonthDay
|
@@ -131,6 +121,12 @@ module OpenHAB
|
|
131
121
|
MonthDay.of(m, d)
|
132
122
|
end
|
133
123
|
|
124
|
+
# Calcalute the maximum number of days in a year before a supplied month
|
125
|
+
# @return [Number] maximum nummber of days in a year before this month
|
126
|
+
def max_days_before(month)
|
127
|
+
java.time.Month.values.select { |i| i < month }.sum(&:max_length)
|
128
|
+
end
|
129
|
+
|
134
130
|
# Parse MonthDay string as defined with by Monthday class without leading double dash "--"
|
135
131
|
def self.parse(string)
|
136
132
|
logger.trace("#{self.class}.parse #{string} (#{string.class})")
|
@@ -146,7 +142,7 @@ module OpenHAB
|
|
146
142
|
|
147
143
|
# Get the maximum (supports leap years) day of the year this month day could be
|
148
144
|
def max_day_of_year
|
149
|
-
day_of_month + month
|
145
|
+
day_of_month + max_days_before(month)
|
150
146
|
end
|
151
147
|
|
152
148
|
# Remove -- from MonthDay string representation
|
@@ -173,7 +169,7 @@ module OpenHAB
|
|
173
169
|
self.<=>(MonthDay.parse(other))
|
174
170
|
when OpenHAB::DSL::Between::MonthDayRange::DayOfYear
|
175
171
|
# Compare with DayOfYear and invert result
|
176
|
-
-other
|
172
|
+
-(other <=> self)
|
177
173
|
else
|
178
174
|
super
|
179
175
|
end
|
@@ -189,9 +189,9 @@ module OpenHAB
|
|
189
189
|
def <=>(other)
|
190
190
|
other_second_of_day = to_second_of_day(other)
|
191
191
|
logger.trace do
|
192
|
-
"SOD(#{sod}) "\
|
193
|
-
"other SOD(#{other_second_of_day}) "\
|
194
|
-
"Other Class (#{other.class}) "\
|
192
|
+
"SOD(#{sod}) " \
|
193
|
+
"other SOD(#{other_second_of_day}) " \
|
194
|
+
"Other Class (#{other.class}) " \
|
195
195
|
"Result (#{sod <=> other_second_of_day})"
|
196
196
|
end
|
197
197
|
sod <=> other_second_of_day
|
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.46.2
|
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-
|
11
|
+
date: 2022-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ruby2_keywords
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.0'
|
55
69
|
description: JRuby Helper Libraries for OpenHAB Scripting
|
56
70
|
email:
|
57
71
|
- broconne@gmail.com
|