openhab-scripting 2.16.1 → 2.18.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.rb +12 -16
- data/lib/openhab/core/entity_lookup.rb +168 -0
- data/lib/openhab/core/openhab_setup.rb +31 -0
- data/lib/openhab/core/osgi.rb +61 -0
- data/lib/openhab/dsl/actions.rb +105 -0
- data/lib/openhab/dsl/dsl.rb +49 -0
- data/lib/openhab/{core/dsl → dsl}/gems.rb +0 -1
- data/lib/openhab/dsl/group.rb +100 -0
- data/lib/openhab/dsl/items/datetime_item.rb +97 -0
- data/lib/openhab/dsl/items/items.rb +46 -0
- data/lib/openhab/dsl/items/number_item.rb +352 -0
- data/lib/openhab/dsl/items/string_item.rb +120 -0
- data/lib/openhab/dsl/monkey_patch/actions/actions.rb +4 -0
- data/lib/openhab/dsl/monkey_patch/actions/script_thing_actions.rb +32 -0
- data/lib/openhab/dsl/monkey_patch/events/events.rb +5 -0
- data/lib/openhab/dsl/monkey_patch/events/item_command.rb +23 -0
- data/lib/openhab/dsl/monkey_patch/events/item_state_changed.rb +35 -0
- data/lib/openhab/dsl/monkey_patch/events/thing_status_info.rb +33 -0
- data/lib/openhab/dsl/monkey_patch/items/contact_item.rb +61 -0
- data/lib/openhab/dsl/monkey_patch/items/dimmer_item.rb +193 -0
- data/lib/openhab/dsl/monkey_patch/items/group_item.rb +37 -0
- data/lib/openhab/dsl/monkey_patch/items/items.rb +133 -0
- data/lib/openhab/dsl/monkey_patch/items/metadata.rb +281 -0
- data/lib/openhab/dsl/monkey_patch/items/persistence.rb +70 -0
- data/lib/openhab/dsl/monkey_patch/items/switch_item.rb +95 -0
- data/lib/openhab/dsl/monkey_patch/ruby/number.rb +39 -0
- data/lib/openhab/dsl/monkey_patch/ruby/range.rb +47 -0
- data/lib/openhab/dsl/monkey_patch/ruby/ruby.rb +8 -0
- data/lib/openhab/dsl/monkey_patch/ruby/string.rb +41 -0
- data/lib/openhab/dsl/monkey_patch/ruby/time.rb +32 -0
- data/lib/openhab/dsl/monkey_patch/types/decimal_type.rb +70 -0
- data/lib/openhab/dsl/monkey_patch/types/on_off_type.rb +51 -0
- data/lib/openhab/dsl/monkey_patch/types/open_closed_type.rb +36 -0
- data/lib/openhab/dsl/monkey_patch/types/percent_type.rb +32 -0
- data/lib/openhab/dsl/monkey_patch/types/quantity_type.rb +69 -0
- data/lib/openhab/dsl/monkey_patch/types/types.rb +8 -0
- data/lib/openhab/dsl/persistence.rb +25 -0
- data/lib/openhab/dsl/rules/automation_rule.rb +342 -0
- data/lib/openhab/dsl/rules/guard.rb +134 -0
- data/lib/openhab/dsl/rules/property.rb +102 -0
- data/lib/openhab/dsl/rules/rule.rb +116 -0
- data/lib/openhab/dsl/rules/rule_config.rb +151 -0
- data/lib/openhab/dsl/rules/triggers/changed.rb +143 -0
- data/lib/openhab/dsl/rules/triggers/channel.rb +53 -0
- data/lib/openhab/dsl/rules/triggers/command.rb +104 -0
- data/lib/openhab/dsl/rules/triggers/cron.rb +177 -0
- data/lib/openhab/dsl/rules/triggers/trigger.rb +124 -0
- data/lib/openhab/dsl/rules/triggers/updated.rb +98 -0
- data/lib/openhab/dsl/states.rb +61 -0
- data/lib/openhab/dsl/things.rb +91 -0
- data/lib/openhab/dsl/time_of_day.rb +232 -0
- data/lib/openhab/dsl/timers.rb +77 -0
- data/lib/openhab/dsl/types/datetime.rb +326 -0
- data/lib/openhab/dsl/types/quantity.rb +290 -0
- data/lib/openhab/dsl/units.rb +39 -0
- data/lib/openhab/log/configuration.rb +21 -0
- data/lib/openhab/log/logger.rb +172 -0
- data/lib/openhab/version.rb +1 -1
- metadata +58 -58
- data/lib/openhab/configuration.rb +0 -16
- data/lib/openhab/core/cron.rb +0 -27
- data/lib/openhab/core/debug.rb +0 -34
- data/lib/openhab/core/dsl.rb +0 -51
- data/lib/openhab/core/dsl/actions.rb +0 -107
- data/lib/openhab/core/dsl/entities.rb +0 -140
- data/lib/openhab/core/dsl/group.rb +0 -93
- data/lib/openhab/core/dsl/items/items.rb +0 -51
- data/lib/openhab/core/dsl/items/number_item.rb +0 -323
- data/lib/openhab/core/dsl/items/string_item.rb +0 -122
- data/lib/openhab/core/dsl/monkey_patch/actions/actions.rb +0 -4
- data/lib/openhab/core/dsl/monkey_patch/actions/script_thing_actions.rb +0 -22
- data/lib/openhab/core/dsl/monkey_patch/events.rb +0 -5
- data/lib/openhab/core/dsl/monkey_patch/events/item_command.rb +0 -13
- data/lib/openhab/core/dsl/monkey_patch/events/item_state_changed.rb +0 -25
- data/lib/openhab/core/dsl/monkey_patch/events/thing_status_info.rb +0 -26
- data/lib/openhab/core/dsl/monkey_patch/items/contact_item.rb +0 -54
- data/lib/openhab/core/dsl/monkey_patch/items/dimmer_item.rb +0 -182
- data/lib/openhab/core/dsl/monkey_patch/items/group_item.rb +0 -27
- data/lib/openhab/core/dsl/monkey_patch/items/items.rb +0 -132
- data/lib/openhab/core/dsl/monkey_patch/items/metadata.rb +0 -283
- data/lib/openhab/core/dsl/monkey_patch/items/persistence.rb +0 -72
- data/lib/openhab/core/dsl/monkey_patch/items/switch_item.rb +0 -87
- data/lib/openhab/core/dsl/monkey_patch/ruby/number.rb +0 -41
- data/lib/openhab/core/dsl/monkey_patch/ruby/range.rb +0 -47
- data/lib/openhab/core/dsl/monkey_patch/ruby/ruby.rb +0 -7
- data/lib/openhab/core/dsl/monkey_patch/ruby/string.rb +0 -43
- data/lib/openhab/core/dsl/monkey_patch/types/decimal_type.rb +0 -60
- data/lib/openhab/core/dsl/monkey_patch/types/on_off_type.rb +0 -41
- data/lib/openhab/core/dsl/monkey_patch/types/open_closed_type.rb +0 -25
- data/lib/openhab/core/dsl/monkey_patch/types/percent_type.rb +0 -23
- data/lib/openhab/core/dsl/monkey_patch/types/quantity_type.rb +0 -58
- data/lib/openhab/core/dsl/monkey_patch/types/types.rb +0 -8
- data/lib/openhab/core/dsl/persistence.rb +0 -27
- data/lib/openhab/core/dsl/property.rb +0 -96
- data/lib/openhab/core/dsl/rule/automation_rule.rb +0 -348
- data/lib/openhab/core/dsl/rule/guard.rb +0 -136
- data/lib/openhab/core/dsl/rule/rule.rb +0 -117
- data/lib/openhab/core/dsl/rule/rule_config.rb +0 -153
- data/lib/openhab/core/dsl/rule/triggers/changed.rb +0 -145
- data/lib/openhab/core/dsl/rule/triggers/channel.rb +0 -55
- data/lib/openhab/core/dsl/rule/triggers/command.rb +0 -106
- data/lib/openhab/core/dsl/rule/triggers/cron.rb +0 -160
- data/lib/openhab/core/dsl/rule/triggers/trigger.rb +0 -126
- data/lib/openhab/core/dsl/rule/triggers/updated.rb +0 -100
- data/lib/openhab/core/dsl/states.rb +0 -63
- data/lib/openhab/core/dsl/things.rb +0 -93
- data/lib/openhab/core/dsl/time_of_day.rb +0 -231
- data/lib/openhab/core/dsl/timers.rb +0 -79
- data/lib/openhab/core/dsl/types/quantity.rb +0 -292
- data/lib/openhab/core/dsl/units.rb +0 -41
- data/lib/openhab/core/log.rb +0 -170
- data/lib/openhab/core/patch_load_path.rb +0 -7
- data/lib/openhab/core/startup_delay.rb +0 -23
- data/lib/openhab/osgi.rb +0 -59
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'java'
|
4
|
+
|
5
|
+
# Import Imperial and SI Units overriding provided values
|
6
|
+
%i[Units ImperialUnits SIUnits].each do |type|
|
7
|
+
Object.send(:remove_const, type)
|
8
|
+
java_import "org.openhab.core.library.unit.#{type}"
|
9
|
+
end
|
10
|
+
|
11
|
+
Object.send(:remove_const, :QuantityType)
|
12
|
+
java_import org.openhab.core.library.types.QuantityType
|
13
|
+
|
14
|
+
module OpenHAB
|
15
|
+
module DSL
|
16
|
+
#
|
17
|
+
# Provides support for interacting with OpenHAB Units of Measurement
|
18
|
+
#
|
19
|
+
module Units
|
20
|
+
java_import 'tec.uom.se.format.SimpleUnitFormat'
|
21
|
+
|
22
|
+
#
|
23
|
+
# Sets a thread local variable to the supplied unit such that classes operating inside the block
|
24
|
+
# can perform automatic conversions to the supplied unit for NumberItems
|
25
|
+
#
|
26
|
+
# @param [Object] unit OpenHAB Unit or String representing unit
|
27
|
+
# @yield [] Block executed in context of the supplied unit
|
28
|
+
#
|
29
|
+
#
|
30
|
+
def unit(unit)
|
31
|
+
unit = SimpleUnitFormat.instance.unitFor(unit) if unit.is_a? String
|
32
|
+
Thread.current.thread_variable_set(:unit, unit)
|
33
|
+
yield
|
34
|
+
ensure
|
35
|
+
Thread.current.thread_variable_set(:unit, nil)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OpenHAB
|
4
|
+
# Supports Logging
|
5
|
+
module Log
|
6
|
+
# This module holds global configuration values
|
7
|
+
module Configuration
|
8
|
+
# -*- coding: utf-8 -*-
|
9
|
+
LOG_PREFIX = 'jsr223.jruby'
|
10
|
+
|
11
|
+
#
|
12
|
+
# Gets the log prefix
|
13
|
+
#
|
14
|
+
# @return [String] Prefix for all log entries
|
15
|
+
#
|
16
|
+
def self.log_prefix
|
17
|
+
LOG_PREFIX
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'openhab/log/configuration'
|
4
|
+
require 'java'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
module OpenHAB
|
8
|
+
#
|
9
|
+
# Provides access to the OpenHAB logging using a Ruby logging methods
|
10
|
+
#
|
11
|
+
module Log
|
12
|
+
#
|
13
|
+
# Ruby Logger that forwards messages at appropriate levels to OpenHAB Logger
|
14
|
+
#
|
15
|
+
class Logger
|
16
|
+
java_import org.slf4j.LoggerFactory
|
17
|
+
|
18
|
+
# @return [Array] Supported logging levels
|
19
|
+
LEVELS = %i[TRACE DEBUG WARN INFO ERROR].freeze
|
20
|
+
|
21
|
+
#
|
22
|
+
# Create a new logger
|
23
|
+
#
|
24
|
+
# @param [String] name of the logger
|
25
|
+
#
|
26
|
+
def initialize(name)
|
27
|
+
@sl4fj_logger = LoggerFactory.getLogger(name)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Dynamically define the methods for each level as identified by the levels constant
|
31
|
+
# This creates a method for each level that looks like this
|
32
|
+
# def <level>(msg=nil, &block)
|
33
|
+
# log(severity: <level>, msg: msg, &block)
|
34
|
+
# end
|
35
|
+
LEVELS.each do |level|
|
36
|
+
method = level.to_s.downcase
|
37
|
+
define_method(method.to_s) do |msg = nil, &block|
|
38
|
+
log(severity: level, msg: msg, &block)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
#
|
45
|
+
# Log a message to the OpenHAB Logger
|
46
|
+
#
|
47
|
+
# @param [Symbol] severity Severity to log message at
|
48
|
+
# @param [Object] msg to log, if no msg supplied and a block is provided,
|
49
|
+
# the msg is taken from the result of the block
|
50
|
+
#
|
51
|
+
def log(severity:, msg: nil)
|
52
|
+
severity = severity.to_sym
|
53
|
+
|
54
|
+
raise ArgumentError, "Unknown Severity #{severity}" unless LEVELS.include? severity
|
55
|
+
|
56
|
+
# Dynamically check enablement of underlying logger, this expands to "is_<level>_enabled"
|
57
|
+
return unless @sl4fj_logger.send("is_#{severity.to_s.downcase}_enabled")
|
58
|
+
|
59
|
+
# Process block if no message provided
|
60
|
+
msg = yield if msg.nil? && block_given?
|
61
|
+
|
62
|
+
msg = message_to_string(msg: msg)
|
63
|
+
|
64
|
+
# Dynamically invoke underlying logger, this expands to "<level>(message)"
|
65
|
+
@sl4fj_logger.send(severity.to_s.downcase, msg)
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Conver the supplied message object to a String
|
70
|
+
#
|
71
|
+
# @param [object] msg object to convert
|
72
|
+
#
|
73
|
+
# @return [String] Msg object as a string
|
74
|
+
#
|
75
|
+
def message_to_string(msg:)
|
76
|
+
case msg
|
77
|
+
when ::String
|
78
|
+
msg
|
79
|
+
when ::Exception
|
80
|
+
"#{msg.message} (#{msg.class})\n#{msg.backtrace&.join("\n")}"
|
81
|
+
else
|
82
|
+
msg.inspect
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
@loggers = {}
|
88
|
+
|
89
|
+
# Return a logger with the configured log prefix plus the calling scripts name
|
90
|
+
|
91
|
+
#
|
92
|
+
# Create a logger for the current class
|
93
|
+
#
|
94
|
+
# @return [Logger] for the current class
|
95
|
+
#
|
96
|
+
def logger
|
97
|
+
Log.logger(self.class.name)
|
98
|
+
end
|
99
|
+
|
100
|
+
class << self
|
101
|
+
#
|
102
|
+
# Injects a logger into the base class
|
103
|
+
#
|
104
|
+
# @param [String] name of the logger
|
105
|
+
#
|
106
|
+
# @return [Logger] for the supplied name
|
107
|
+
#
|
108
|
+
def logger(name)
|
109
|
+
name ||= self.class.name
|
110
|
+
@loggers[name] ||= Log.logger_for(name)
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Configure a logger for the supplied class name
|
115
|
+
#
|
116
|
+
# @param [String] classname to configure logger for
|
117
|
+
#
|
118
|
+
# @return [Logger] for the supplied classname
|
119
|
+
#
|
120
|
+
def logger_for(classname)
|
121
|
+
configure_logger_for(classname)
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
#
|
127
|
+
# Configure a logger for the supplied classname
|
128
|
+
#
|
129
|
+
# @param [String] classname to create logger for
|
130
|
+
#
|
131
|
+
# @return [Logger] Logger for the supplied classname
|
132
|
+
#
|
133
|
+
def configure_logger_for(classname)
|
134
|
+
log_prefix = Configuration.log_prefix
|
135
|
+
log_prefix += if classname
|
136
|
+
".#{classname}"
|
137
|
+
else
|
138
|
+
".#{log_caller}"
|
139
|
+
end
|
140
|
+
Logger.new(log_prefix)
|
141
|
+
end
|
142
|
+
|
143
|
+
#
|
144
|
+
# Figure out the log prefix
|
145
|
+
#
|
146
|
+
# @return [String] Prefix for log messages
|
147
|
+
#
|
148
|
+
def log_caller
|
149
|
+
caller_locations.map(&:path)
|
150
|
+
.grep_v(%r{openhab/core/})
|
151
|
+
.grep_v(/rubygems/)
|
152
|
+
.grep_v(%r{lib/ruby})
|
153
|
+
.first
|
154
|
+
.yield_self { |caller| File.basename(caller, '.*') }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
#
|
159
|
+
# Add logger method to the object that includes this module
|
160
|
+
#
|
161
|
+
# @param [Object] base Object to add method to
|
162
|
+
#
|
163
|
+
#
|
164
|
+
def self.included(base)
|
165
|
+
class << base
|
166
|
+
def logger
|
167
|
+
Log.logger(self.class.name)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
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: 2.
|
4
|
+
version: 2.18.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: 2021-02-
|
11
|
+
date: 2021-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -32,62 +32,62 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- lib/openhab.rb
|
35
|
-
- lib/openhab/
|
36
|
-
- lib/openhab/core/
|
37
|
-
- lib/openhab/core/
|
38
|
-
- lib/openhab/
|
39
|
-
- lib/openhab/
|
40
|
-
- lib/openhab/
|
41
|
-
- lib/openhab/
|
42
|
-
- lib/openhab/
|
43
|
-
- lib/openhab/
|
44
|
-
- lib/openhab/
|
45
|
-
- lib/openhab/
|
46
|
-
- lib/openhab/
|
47
|
-
- lib/openhab/
|
48
|
-
- lib/openhab/
|
49
|
-
- lib/openhab/
|
50
|
-
- lib/openhab/
|
51
|
-
- lib/openhab/
|
52
|
-
- lib/openhab/
|
53
|
-
- lib/openhab/
|
54
|
-
- lib/openhab/
|
55
|
-
- lib/openhab/
|
56
|
-
- lib/openhab/
|
57
|
-
- lib/openhab/
|
58
|
-
- lib/openhab/
|
59
|
-
- lib/openhab/
|
60
|
-
- lib/openhab/
|
61
|
-
- lib/openhab/
|
62
|
-
- lib/openhab/
|
63
|
-
- lib/openhab/
|
64
|
-
- lib/openhab/
|
65
|
-
- lib/openhab/
|
66
|
-
- lib/openhab/
|
67
|
-
- lib/openhab/
|
68
|
-
- lib/openhab/
|
69
|
-
- lib/openhab/
|
70
|
-
- lib/openhab/
|
71
|
-
- lib/openhab/
|
72
|
-
- lib/openhab/
|
73
|
-
- lib/openhab/
|
74
|
-
- lib/openhab/
|
75
|
-
- lib/openhab/
|
76
|
-
- lib/openhab/
|
77
|
-
- lib/openhab/
|
78
|
-
- lib/openhab/
|
79
|
-
- lib/openhab/
|
80
|
-
- lib/openhab/
|
81
|
-
- lib/openhab/
|
82
|
-
- lib/openhab/
|
83
|
-
- lib/openhab/
|
84
|
-
- lib/openhab/
|
85
|
-
- lib/openhab/
|
86
|
-
- lib/openhab/
|
87
|
-
- lib/openhab/
|
88
|
-
- lib/openhab/
|
89
|
-
- lib/openhab/
|
90
|
-
- lib/openhab/
|
35
|
+
- lib/openhab/core/entity_lookup.rb
|
36
|
+
- lib/openhab/core/openhab_setup.rb
|
37
|
+
- lib/openhab/core/osgi.rb
|
38
|
+
- lib/openhab/dsl/actions.rb
|
39
|
+
- lib/openhab/dsl/dsl.rb
|
40
|
+
- lib/openhab/dsl/gems.rb
|
41
|
+
- lib/openhab/dsl/group.rb
|
42
|
+
- lib/openhab/dsl/items/datetime_item.rb
|
43
|
+
- lib/openhab/dsl/items/items.rb
|
44
|
+
- lib/openhab/dsl/items/number_item.rb
|
45
|
+
- lib/openhab/dsl/items/string_item.rb
|
46
|
+
- lib/openhab/dsl/monkey_patch/actions/actions.rb
|
47
|
+
- lib/openhab/dsl/monkey_patch/actions/script_thing_actions.rb
|
48
|
+
- lib/openhab/dsl/monkey_patch/events/events.rb
|
49
|
+
- lib/openhab/dsl/monkey_patch/events/item_command.rb
|
50
|
+
- lib/openhab/dsl/monkey_patch/events/item_state_changed.rb
|
51
|
+
- lib/openhab/dsl/monkey_patch/events/thing_status_info.rb
|
52
|
+
- lib/openhab/dsl/monkey_patch/items/contact_item.rb
|
53
|
+
- lib/openhab/dsl/monkey_patch/items/dimmer_item.rb
|
54
|
+
- lib/openhab/dsl/monkey_patch/items/group_item.rb
|
55
|
+
- lib/openhab/dsl/monkey_patch/items/items.rb
|
56
|
+
- lib/openhab/dsl/monkey_patch/items/metadata.rb
|
57
|
+
- lib/openhab/dsl/monkey_patch/items/persistence.rb
|
58
|
+
- lib/openhab/dsl/monkey_patch/items/switch_item.rb
|
59
|
+
- lib/openhab/dsl/monkey_patch/ruby/number.rb
|
60
|
+
- lib/openhab/dsl/monkey_patch/ruby/range.rb
|
61
|
+
- lib/openhab/dsl/monkey_patch/ruby/ruby.rb
|
62
|
+
- lib/openhab/dsl/monkey_patch/ruby/string.rb
|
63
|
+
- lib/openhab/dsl/monkey_patch/ruby/time.rb
|
64
|
+
- lib/openhab/dsl/monkey_patch/types/decimal_type.rb
|
65
|
+
- lib/openhab/dsl/monkey_patch/types/on_off_type.rb
|
66
|
+
- lib/openhab/dsl/monkey_patch/types/open_closed_type.rb
|
67
|
+
- lib/openhab/dsl/monkey_patch/types/percent_type.rb
|
68
|
+
- lib/openhab/dsl/monkey_patch/types/quantity_type.rb
|
69
|
+
- lib/openhab/dsl/monkey_patch/types/types.rb
|
70
|
+
- lib/openhab/dsl/persistence.rb
|
71
|
+
- lib/openhab/dsl/rules/automation_rule.rb
|
72
|
+
- lib/openhab/dsl/rules/guard.rb
|
73
|
+
- lib/openhab/dsl/rules/property.rb
|
74
|
+
- lib/openhab/dsl/rules/rule.rb
|
75
|
+
- lib/openhab/dsl/rules/rule_config.rb
|
76
|
+
- lib/openhab/dsl/rules/triggers/changed.rb
|
77
|
+
- lib/openhab/dsl/rules/triggers/channel.rb
|
78
|
+
- lib/openhab/dsl/rules/triggers/command.rb
|
79
|
+
- lib/openhab/dsl/rules/triggers/cron.rb
|
80
|
+
- lib/openhab/dsl/rules/triggers/trigger.rb
|
81
|
+
- lib/openhab/dsl/rules/triggers/updated.rb
|
82
|
+
- lib/openhab/dsl/states.rb
|
83
|
+
- lib/openhab/dsl/things.rb
|
84
|
+
- lib/openhab/dsl/time_of_day.rb
|
85
|
+
- lib/openhab/dsl/timers.rb
|
86
|
+
- lib/openhab/dsl/types/datetime.rb
|
87
|
+
- lib/openhab/dsl/types/quantity.rb
|
88
|
+
- lib/openhab/dsl/units.rb
|
89
|
+
- lib/openhab/log/configuration.rb
|
90
|
+
- lib/openhab/log/logger.rb
|
91
91
|
- lib/openhab/version.rb
|
92
92
|
homepage: https://boc-tothefuture.github.io/openhab-jruby/
|
93
93
|
licenses: []
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This module holds global configuration values
|
4
|
-
module Configuration
|
5
|
-
# -*- coding: utf-8 -*-
|
6
|
-
LOG_PREFIX = 'jsr223.jruby'
|
7
|
-
|
8
|
-
#
|
9
|
-
# Gets the log prefix
|
10
|
-
#
|
11
|
-
# @return [String] Prefix for all log entries
|
12
|
-
#
|
13
|
-
def self.log_prefix
|
14
|
-
LOG_PREFIX
|
15
|
-
end
|
16
|
-
end
|
data/lib/openhab/core/cron.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module OpenHAB
|
4
|
-
module Core
|
5
|
-
#
|
6
|
-
# Module for Cron related methods
|
7
|
-
#
|
8
|
-
module Cron
|
9
|
-
#
|
10
|
-
# Retruns a default map for cron expressions that fires every second
|
11
|
-
# This map is usually updated via merge by other methods to refine cron type triggers.
|
12
|
-
#
|
13
|
-
# @return [Map] Map with symbols for :seconds, :minute, :hour, :dom, :month, :dow configured to fire every second
|
14
|
-
#
|
15
|
-
def cron_expression_map
|
16
|
-
{
|
17
|
-
second: '*',
|
18
|
-
minute: '*',
|
19
|
-
hour: '*',
|
20
|
-
dom: '?',
|
21
|
-
month: '*',
|
22
|
-
dow: '?'
|
23
|
-
}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/openhab/core/debug.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'pp'
|
4
|
-
require 'core/log'
|
5
|
-
require 'core/dsl/things'
|
6
|
-
|
7
|
-
#
|
8
|
-
# Module to support debugging information about the Ruby or OpenHAB environment
|
9
|
-
#
|
10
|
-
module Debug
|
11
|
-
include Logging
|
12
|
-
include OpenHAB::Core::DSL::Things
|
13
|
-
|
14
|
-
#
|
15
|
-
# Print the loadpath, instance and global variables
|
16
|
-
#
|
17
|
-
def debug_variables
|
18
|
-
pp "Instance #{instance_variables}"
|
19
|
-
pp "Global #{global_variables}"
|
20
|
-
pp "Load Path #{$LOAD_PATH}"
|
21
|
-
# pp "Constants #{Module.constants}"
|
22
|
-
end
|
23
|
-
|
24
|
-
#
|
25
|
-
# Print information about the OpenHAB instance
|
26
|
-
#
|
27
|
-
def debug_openhab
|
28
|
-
logger.debug { "Things - Count #{things.size}" }
|
29
|
-
things.each do |thing|
|
30
|
-
logger.debug { "Thing:(#{thing.label}) UID:(#{thing.uid}) Channels(#{thing.channels.map(&:uid).join(', ')})" }
|
31
|
-
end
|
32
|
-
# logger.debug { $things.getAll.join(", ") }
|
33
|
-
end
|
34
|
-
end
|