openhab-scripting 2.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/workflow.yml +327 -0
- data/.gitignore +17 -0
- data/.java-version +1 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +113 -0
- data/Gemfile +28 -0
- data/Gemfile.lock +245 -0
- data/Guardfile +35 -0
- data/LICENSE +277 -0
- data/README.md +23 -0
- data/Rakefile +406 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/config/userdata/config/org/openhab/restauth.config +3 -0
- data/cucumber.yml +1 -0
- data/docs/_config.yml +135 -0
- data/docs/contributing/index.md +47 -0
- data/docs/examples/conversions.md +123 -0
- data/docs/examples/index.md +61 -0
- data/docs/index.md +19 -0
- data/docs/installation/index.md +26 -0
- data/docs/motivation/index.md +27 -0
- data/docs/usage/execution.md +9 -0
- data/docs/usage/execution/delay.md +48 -0
- data/docs/usage/execution/otherwise.md +30 -0
- data/docs/usage/execution/run.md +70 -0
- data/docs/usage/execution/triggered.md +48 -0
- data/docs/usage/guards.md +51 -0
- data/docs/usage/guards/between.md +30 -0
- data/docs/usage/guards/not_if.md +41 -0
- data/docs/usage/guards/only_if.md +40 -0
- data/docs/usage/index.md +11 -0
- data/docs/usage/items.md +66 -0
- data/docs/usage/items/contact.md +84 -0
- data/docs/usage/items/dimmer.md +147 -0
- data/docs/usage/items/groups.md +76 -0
- data/docs/usage/items/number.md +225 -0
- data/docs/usage/items/string.md +49 -0
- data/docs/usage/items/switch.md +85 -0
- data/docs/usage/misc.md +7 -0
- data/docs/usage/misc/actions.md +108 -0
- data/docs/usage/misc/duration.md +21 -0
- data/docs/usage/misc/gems.md +25 -0
- data/docs/usage/misc/logging.md +21 -0
- data/docs/usage/misc/metadata.md +128 -0
- data/docs/usage/misc/store_states.md +42 -0
- data/docs/usage/misc/time_of_day.md +69 -0
- data/docs/usage/misc/timers.md +67 -0
- data/docs/usage/rule.md +43 -0
- data/docs/usage/things.md +29 -0
- data/docs/usage/triggers.md +8 -0
- data/docs/usage/triggers/changed.md +57 -0
- data/docs/usage/triggers/channel.md +54 -0
- data/docs/usage/triggers/command.md +69 -0
- data/docs/usage/triggers/cron.md +19 -0
- data/docs/usage/triggers/every.md +76 -0
- data/docs/usage/triggers/updated.md +78 -0
- data/lib/openhab.rb +39 -0
- data/lib/openhab/configuration.rb +16 -0
- data/lib/openhab/core/cron.rb +27 -0
- data/lib/openhab/core/debug.rb +34 -0
- data/lib/openhab/core/dsl.rb +47 -0
- data/lib/openhab/core/dsl/actions.rb +107 -0
- data/lib/openhab/core/dsl/entities.rb +103 -0
- data/lib/openhab/core/dsl/gems.rb +29 -0
- data/lib/openhab/core/dsl/group.rb +91 -0
- data/lib/openhab/core/dsl/items/items.rb +39 -0
- data/lib/openhab/core/dsl/items/number_item.rb +217 -0
- data/lib/openhab/core/dsl/items/string_item.rb +102 -0
- data/lib/openhab/core/dsl/monkey_patch/actions/actions.rb +4 -0
- data/lib/openhab/core/dsl/monkey_patch/actions/script_thing_actions.rb +22 -0
- data/lib/openhab/core/dsl/monkey_patch/events.rb +5 -0
- data/lib/openhab/core/dsl/monkey_patch/events/item_command.rb +13 -0
- data/lib/openhab/core/dsl/monkey_patch/events/item_state_changed.rb +25 -0
- data/lib/openhab/core/dsl/monkey_patch/events/thing_status_info.rb +26 -0
- data/lib/openhab/core/dsl/monkey_patch/items/contact_item.rb +54 -0
- data/lib/openhab/core/dsl/monkey_patch/items/dimmer_item.rb +125 -0
- data/lib/openhab/core/dsl/monkey_patch/items/group_item.rb +27 -0
- data/lib/openhab/core/dsl/monkey_patch/items/items.rb +130 -0
- data/lib/openhab/core/dsl/monkey_patch/items/metadata.rb +259 -0
- data/lib/openhab/core/dsl/monkey_patch/items/switch_item.rb +86 -0
- data/lib/openhab/core/dsl/monkey_patch/ruby/number.rb +69 -0
- data/lib/openhab/core/dsl/monkey_patch/ruby/range.rb +46 -0
- data/lib/openhab/core/dsl/monkey_patch/ruby/ruby.rb +5 -0
- data/lib/openhab/core/dsl/monkey_patch/types/decimal_type.rb +24 -0
- data/lib/openhab/core/dsl/monkey_patch/types/on_off_type.rb +41 -0
- data/lib/openhab/core/dsl/monkey_patch/types/open_closed_type.rb +25 -0
- data/lib/openhab/core/dsl/monkey_patch/types/percent_type.rb +23 -0
- data/lib/openhab/core/dsl/monkey_patch/types/types.rb +7 -0
- data/lib/openhab/core/dsl/property.rb +85 -0
- data/lib/openhab/core/dsl/rule/channel.rb +41 -0
- data/lib/openhab/core/dsl/rule/cron.rb +115 -0
- data/lib/openhab/core/dsl/rule/guard.rb +99 -0
- data/lib/openhab/core/dsl/rule/item.rb +207 -0
- data/lib/openhab/core/dsl/rule/rule.rb +374 -0
- data/lib/openhab/core/dsl/rule/triggers.rb +77 -0
- data/lib/openhab/core/dsl/states.rb +63 -0
- data/lib/openhab/core/dsl/things.rb +93 -0
- data/lib/openhab/core/dsl/time_of_day.rb +203 -0
- data/lib/openhab/core/dsl/timers.rb +85 -0
- data/lib/openhab/core/dsl/types/quantity.rb +255 -0
- data/lib/openhab/core/dsl/units.rb +41 -0
- data/lib/openhab/core/duration.rb +69 -0
- data/lib/openhab/core/log.rb +175 -0
- data/lib/openhab/core/patch_load_path.rb +7 -0
- data/lib/openhab/core/startup_delay.rb +22 -0
- data/lib/openhab/osgi.rb +52 -0
- data/lib/openhab/version.rb +9 -0
- data/openhab-scripting.gemspec +30 -0
- data/openhab_rules/warmup.rb +5 -0
- metadata +157 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'core/log'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Module when included will pause the current thread until OpenHAB is ready for interaction
|
7
|
+
#
|
8
|
+
module StartupDelay
|
9
|
+
include Logging
|
10
|
+
|
11
|
+
CHECK_DELAY = 10
|
12
|
+
private_constant :CHECK_DELAY
|
13
|
+
|
14
|
+
logger.info('Checking for Automation manager')
|
15
|
+
# rubocop: disable Style/GlobalVars
|
16
|
+
until $scriptExtension.get('automationManager')
|
17
|
+
logger.info("Automation manager not loaded, checking again in #{CHECK_DELAY} seconds.")
|
18
|
+
sleep CHECK_DELAY
|
19
|
+
end
|
20
|
+
# rubocop: enable Style/GlobalVars
|
21
|
+
logger.info 'Automation manager check complete.'
|
22
|
+
end
|
data/lib/openhab/osgi.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'java'
|
4
|
+
require 'openhab/core/log'
|
5
|
+
|
6
|
+
module OpenHAB
|
7
|
+
#
|
8
|
+
# OSGI services interface
|
9
|
+
#
|
10
|
+
class OSGI
|
11
|
+
include Logging
|
12
|
+
|
13
|
+
java_import org.openhab.core.model.script.actions.ScriptExecution
|
14
|
+
java_import org.osgi.framework.FrameworkUtil
|
15
|
+
|
16
|
+
#
|
17
|
+
# @param name [String] The service name
|
18
|
+
#
|
19
|
+
# @return [Service]
|
20
|
+
#
|
21
|
+
def self.service(name)
|
22
|
+
ref = bundle_context.getServiceReference(name)
|
23
|
+
service = bundle_context.getService(ref) if ref
|
24
|
+
logger.trace "OSGI service(#{service}) found for '#{name}' using OSGI Service Reference #{ref}"
|
25
|
+
|
26
|
+
service
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# @param name [String] The service name
|
31
|
+
# @param filter [String] Filter for service names. See https://docs.osgi.org/javadoc/r4v43/core/org/osgi/framework/Filter.html
|
32
|
+
#
|
33
|
+
# @return [Array] An array of services
|
34
|
+
#
|
35
|
+
def self.services(name, filter: nil)
|
36
|
+
bundle_context.getServiceReferences(name, filter)&.map do |reference|
|
37
|
+
bundle_context.getService(reference)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.bundle_context
|
42
|
+
@bundle_context ||= bundle.getBundleContext
|
43
|
+
end
|
44
|
+
private_class_method :bundle_context
|
45
|
+
|
46
|
+
# Get the OSGI Bundle for ScriptExtension Class
|
47
|
+
def self.bundle
|
48
|
+
@bundle ||= FrameworkUtil.getBundle($scriptExtension.class)
|
49
|
+
end
|
50
|
+
private_class_method :bundle
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/openhab/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'openhab-scripting'
|
7
|
+
spec.version = OpenHAB::VERSION
|
8
|
+
spec.authors = ["Brian O'Connell"]
|
9
|
+
spec.email = ['broconne@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'JRuby Helper Libraries for OpenHAB Scripting'
|
12
|
+
spec.description = 'JRuby Helper Libraries for OpenHAB Scripting'
|
13
|
+
spec.homepage = 'https://boc-tothefuture.github.io/openhab-jruby/'
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
15
|
+
|
16
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
17
|
+
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/boc-tothefuture/openhab-jruby'
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/boc-tothefuture/openhab-jruby/blob/main/CHANGELOG.md'
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|bundle)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openhab-scripting
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.9.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian O'Connell
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: JRuby Helper Libraries for OpenHAB Scripting
|
14
|
+
email:
|
15
|
+
- broconne@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".github/workflows/workflow.yml"
|
21
|
+
- ".gitignore"
|
22
|
+
- ".java-version"
|
23
|
+
- ".rspec"
|
24
|
+
- ".yardopts"
|
25
|
+
- CHANGELOG.md
|
26
|
+
- Gemfile
|
27
|
+
- Gemfile.lock
|
28
|
+
- Guardfile
|
29
|
+
- LICENSE
|
30
|
+
- README.md
|
31
|
+
- Rakefile
|
32
|
+
- bin/console
|
33
|
+
- bin/setup
|
34
|
+
- config/userdata/config/org/openhab/restauth.config
|
35
|
+
- cucumber.yml
|
36
|
+
- docs/_config.yml
|
37
|
+
- docs/contributing/index.md
|
38
|
+
- docs/examples/conversions.md
|
39
|
+
- docs/examples/index.md
|
40
|
+
- docs/index.md
|
41
|
+
- docs/installation/index.md
|
42
|
+
- docs/motivation/index.md
|
43
|
+
- docs/usage/execution.md
|
44
|
+
- docs/usage/execution/delay.md
|
45
|
+
- docs/usage/execution/otherwise.md
|
46
|
+
- docs/usage/execution/run.md
|
47
|
+
- docs/usage/execution/triggered.md
|
48
|
+
- docs/usage/guards.md
|
49
|
+
- docs/usage/guards/between.md
|
50
|
+
- docs/usage/guards/not_if.md
|
51
|
+
- docs/usage/guards/only_if.md
|
52
|
+
- docs/usage/index.md
|
53
|
+
- docs/usage/items.md
|
54
|
+
- docs/usage/items/contact.md
|
55
|
+
- docs/usage/items/dimmer.md
|
56
|
+
- docs/usage/items/groups.md
|
57
|
+
- docs/usage/items/number.md
|
58
|
+
- docs/usage/items/string.md
|
59
|
+
- docs/usage/items/switch.md
|
60
|
+
- docs/usage/misc.md
|
61
|
+
- docs/usage/misc/actions.md
|
62
|
+
- docs/usage/misc/duration.md
|
63
|
+
- docs/usage/misc/gems.md
|
64
|
+
- docs/usage/misc/logging.md
|
65
|
+
- docs/usage/misc/metadata.md
|
66
|
+
- docs/usage/misc/store_states.md
|
67
|
+
- docs/usage/misc/time_of_day.md
|
68
|
+
- docs/usage/misc/timers.md
|
69
|
+
- docs/usage/rule.md
|
70
|
+
- docs/usage/things.md
|
71
|
+
- docs/usage/triggers.md
|
72
|
+
- docs/usage/triggers/changed.md
|
73
|
+
- docs/usage/triggers/channel.md
|
74
|
+
- docs/usage/triggers/command.md
|
75
|
+
- docs/usage/triggers/cron.md
|
76
|
+
- docs/usage/triggers/every.md
|
77
|
+
- docs/usage/triggers/updated.md
|
78
|
+
- lib/openhab.rb
|
79
|
+
- lib/openhab/configuration.rb
|
80
|
+
- lib/openhab/core/cron.rb
|
81
|
+
- lib/openhab/core/debug.rb
|
82
|
+
- lib/openhab/core/dsl.rb
|
83
|
+
- lib/openhab/core/dsl/actions.rb
|
84
|
+
- lib/openhab/core/dsl/entities.rb
|
85
|
+
- lib/openhab/core/dsl/gems.rb
|
86
|
+
- lib/openhab/core/dsl/group.rb
|
87
|
+
- lib/openhab/core/dsl/items/items.rb
|
88
|
+
- lib/openhab/core/dsl/items/number_item.rb
|
89
|
+
- lib/openhab/core/dsl/items/string_item.rb
|
90
|
+
- lib/openhab/core/dsl/monkey_patch/actions/actions.rb
|
91
|
+
- lib/openhab/core/dsl/monkey_patch/actions/script_thing_actions.rb
|
92
|
+
- lib/openhab/core/dsl/monkey_patch/events.rb
|
93
|
+
- lib/openhab/core/dsl/monkey_patch/events/item_command.rb
|
94
|
+
- lib/openhab/core/dsl/monkey_patch/events/item_state_changed.rb
|
95
|
+
- lib/openhab/core/dsl/monkey_patch/events/thing_status_info.rb
|
96
|
+
- lib/openhab/core/dsl/monkey_patch/items/contact_item.rb
|
97
|
+
- lib/openhab/core/dsl/monkey_patch/items/dimmer_item.rb
|
98
|
+
- lib/openhab/core/dsl/monkey_patch/items/group_item.rb
|
99
|
+
- lib/openhab/core/dsl/monkey_patch/items/items.rb
|
100
|
+
- lib/openhab/core/dsl/monkey_patch/items/metadata.rb
|
101
|
+
- lib/openhab/core/dsl/monkey_patch/items/switch_item.rb
|
102
|
+
- lib/openhab/core/dsl/monkey_patch/ruby/number.rb
|
103
|
+
- lib/openhab/core/dsl/monkey_patch/ruby/range.rb
|
104
|
+
- lib/openhab/core/dsl/monkey_patch/ruby/ruby.rb
|
105
|
+
- lib/openhab/core/dsl/monkey_patch/types/decimal_type.rb
|
106
|
+
- lib/openhab/core/dsl/monkey_patch/types/on_off_type.rb
|
107
|
+
- lib/openhab/core/dsl/monkey_patch/types/open_closed_type.rb
|
108
|
+
- lib/openhab/core/dsl/monkey_patch/types/percent_type.rb
|
109
|
+
- lib/openhab/core/dsl/monkey_patch/types/types.rb
|
110
|
+
- lib/openhab/core/dsl/property.rb
|
111
|
+
- lib/openhab/core/dsl/rule/channel.rb
|
112
|
+
- lib/openhab/core/dsl/rule/cron.rb
|
113
|
+
- lib/openhab/core/dsl/rule/guard.rb
|
114
|
+
- lib/openhab/core/dsl/rule/item.rb
|
115
|
+
- lib/openhab/core/dsl/rule/rule.rb
|
116
|
+
- lib/openhab/core/dsl/rule/triggers.rb
|
117
|
+
- lib/openhab/core/dsl/states.rb
|
118
|
+
- lib/openhab/core/dsl/things.rb
|
119
|
+
- lib/openhab/core/dsl/time_of_day.rb
|
120
|
+
- lib/openhab/core/dsl/timers.rb
|
121
|
+
- lib/openhab/core/dsl/types/quantity.rb
|
122
|
+
- lib/openhab/core/dsl/units.rb
|
123
|
+
- lib/openhab/core/duration.rb
|
124
|
+
- lib/openhab/core/log.rb
|
125
|
+
- lib/openhab/core/patch_load_path.rb
|
126
|
+
- lib/openhab/core/startup_delay.rb
|
127
|
+
- lib/openhab/osgi.rb
|
128
|
+
- lib/openhab/version.rb
|
129
|
+
- openhab-scripting.gemspec
|
130
|
+
- openhab_rules/warmup.rb
|
131
|
+
homepage: https://boc-tothefuture.github.io/openhab-jruby/
|
132
|
+
licenses: []
|
133
|
+
metadata:
|
134
|
+
homepage_uri: https://boc-tothefuture.github.io/openhab-jruby/
|
135
|
+
source_code_uri: https://github.com/boc-tothefuture/openhab-jruby
|
136
|
+
changelog_uri: https://github.com/boc-tothefuture/openhab-jruby/blob/main/CHANGELOG.md
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 2.5.0
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.7.6.2
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: JRuby Helper Libraries for OpenHAB Scripting
|
157
|
+
test_files: []
|