openhab-scripting 5.27.2 → 5.28.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/core/entity_lookup.rb +55 -3
- data/lib/openhab/dsl/sitemaps/builder.rb +11 -2
- data/lib/openhab/dsl/version.rb +1 -1
- data/lib/openhab/dsl.rb +9 -55
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c99d5ea37c52514af7dfa8b5316c8b8d196f46dac4fb4ce557ac01963de8bb51
|
4
|
+
data.tar.gz: d2ee0a5934babcd911d2584ba7e20f73164e568108657121870422fa247d6c6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c353e9b41fb5e11e95eaf2fe8d048caf7b3aa6873c7a6017a0d099f4738a67c8b2ae1015d2a2c2248a2089ebb42d7fafecafcc5613998d39739fcf44dd77ee92
|
7
|
+
data.tar.gz: a54105ab52153231d2ee7871f74ae5d1743c23c18fa582a09114e15c754a0ccd86bd9772298352f7c9d4f191aa8f47b3807ca20919473f1795da4e0e3d643f2e
|
@@ -13,9 +13,6 @@ module OpenHAB
|
|
13
13
|
# it must be replaced with an underscore `_`. So to access `astro:sun:home`, use `astro_sun_home`
|
14
14
|
# as an alternative to `things["astro:sun:home"]`
|
15
15
|
#
|
16
|
-
# @see OpenHAB::DSL.items items[]
|
17
|
-
# @see OpenHAB::DSL.things things[]
|
18
|
-
#
|
19
16
|
# @example Accessing Items and Groups
|
20
17
|
# gAll_Lights # Access the gAll_Lights group. It is the same as items["gAll_Lights"]
|
21
18
|
# Kitchen_Light.on # The openHAB object for the Kitchen_Light item and send an ON command
|
@@ -66,6 +63,61 @@ module OpenHAB
|
|
66
63
|
end
|
67
64
|
end
|
68
65
|
|
66
|
+
#
|
67
|
+
# Fetches all items from the item registry
|
68
|
+
#
|
69
|
+
# @return [Core::Items::Registry]
|
70
|
+
#
|
71
|
+
# The examples all assume the following items exist.
|
72
|
+
#
|
73
|
+
# ```xtend
|
74
|
+
# Dimmer DimmerTest "Test Dimmer"
|
75
|
+
# Switch SwitchTest "Test Switch"
|
76
|
+
# ```
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# logger.info("Item Count: #{items.count}") # Item Count: 2
|
80
|
+
# logger.info("Items: #{items.map(&:label).sort.join(', ')}") # Items: Test Dimmer, Test Switch'
|
81
|
+
# logger.info("DimmerTest exists? #{items.key?('DimmerTest')}") # DimmerTest exists? true
|
82
|
+
# logger.info("StringTest exists? #{items.key?('StringTest')}") # StringTest exists? false
|
83
|
+
#
|
84
|
+
# @example
|
85
|
+
# rule 'Use dynamic item lookup to increase related dimmer brightness when switch is turned on' do
|
86
|
+
# changed SwitchTest, to: ON
|
87
|
+
# triggered { |item| items[item.name.gsub('Switch','Dimmer')].brighten(10) }
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# @example
|
91
|
+
# rule 'search for a suitable item' do
|
92
|
+
# on_load
|
93
|
+
# triggered do
|
94
|
+
# # Send ON to DimmerTest if it exists, otherwise send it to SwitchTest
|
95
|
+
# (items['DimmerTest'] || items['SwitchTest'])&.on
|
96
|
+
# end
|
97
|
+
# end
|
98
|
+
#
|
99
|
+
def items
|
100
|
+
Core::Items::Registry.instance
|
101
|
+
end
|
102
|
+
|
103
|
+
#
|
104
|
+
# Get all things known to openHAB
|
105
|
+
#
|
106
|
+
# @return [Core::Things::Registry] all Thing objects known to openHAB
|
107
|
+
#
|
108
|
+
# @example
|
109
|
+
# things.each { |thing| logger.info("Thing: #{thing.uid}")}
|
110
|
+
# logger.info("Thing: #{things['astro:sun:home'].uid}")
|
111
|
+
# homie_things = things.select { |t| t.thing_type_uid == "mqtt:homie300" }
|
112
|
+
# zwave_things = things.select { |t| t.binding_id == "zwave" }
|
113
|
+
# homeseer_dimmers = zwave_things.select { |t| t.thing_type_uid.id == "homeseer_hswd200_00_000" }
|
114
|
+
# things['zwave:device:512:node90'].uid.bridge_ids # => ["512"]
|
115
|
+
# things['mqtt:topic:4'].uid.bridge_ids # => []
|
116
|
+
#
|
117
|
+
def things
|
118
|
+
Core::Things::Registry.instance
|
119
|
+
end
|
120
|
+
|
69
121
|
#
|
70
122
|
# Automatically looks up openHAB items and things in appropriate registries
|
71
123
|
#
|
@@ -127,7 +127,12 @@ module OpenHAB
|
|
127
127
|
# One or more value color rules (see {#value_color})
|
128
128
|
# @param icon_color [String, Hash<String, String>, Hash<Array<String>, String>, nil]
|
129
129
|
# One or more icon color rules (see {#icon_color})
|
130
|
-
# @param visibility [String,
|
130
|
+
# @param visibility [String,
|
131
|
+
# Core::Types::State,
|
132
|
+
# Array<String>,
|
133
|
+
# Array<Core::Types::State>,
|
134
|
+
# Array<Array<String>>,
|
135
|
+
# nil]
|
131
136
|
# One or more visibility rules (see {#visibility})
|
132
137
|
# @!visibility private
|
133
138
|
def initialize(type,
|
@@ -286,8 +291,12 @@ module OpenHAB
|
|
286
291
|
supports_and_conditions = SitemapBuilder.factory.respond_to?(:create_condition)
|
287
292
|
|
288
293
|
Array.wrap(conditions).each do |c|
|
294
|
+
c = c.to_s if c.is_a?(Core::Types::State)
|
295
|
+
unless c.is_a?(String) || c.is_a?(Symbol)
|
296
|
+
raise ArgumentError, "#{c.inspect} is not a valid condition data type for #{inspect}"
|
297
|
+
end
|
289
298
|
unless (match = CONDITION_PATTERN.match(c))
|
290
|
-
raise ArgumentError, "Syntax error in condition #{c.inspect}"
|
299
|
+
raise ArgumentError, "Syntax error in condition #{c.inspect} for #{inspect}"
|
291
300
|
end
|
292
301
|
|
293
302
|
condition = supports_and_conditions ? SitemapBuilder.factory.create_condition : container
|
data/lib/openhab/dsl/version.rb
CHANGED
data/lib/openhab/dsl.rb
CHANGED
@@ -51,6 +51,8 @@ module OpenHAB
|
|
51
51
|
|
52
52
|
@debouncers = java.util.concurrent.ConcurrentHashMap.new
|
53
53
|
|
54
|
+
module_function :items, :things
|
55
|
+
|
54
56
|
module_function
|
55
57
|
|
56
58
|
# @!group Rule Creation
|
@@ -229,6 +231,13 @@ module OpenHAB
|
|
229
231
|
|
230
232
|
# @!group Object Access
|
231
233
|
|
234
|
+
# @!parse
|
235
|
+
# # (see Core::EntityLookup#items)
|
236
|
+
# def items; end
|
237
|
+
#
|
238
|
+
# # (see Core::EntityLookup#things)
|
239
|
+
# def things; end
|
240
|
+
|
232
241
|
#
|
233
242
|
# (see Core::ValueCache)
|
234
243
|
#
|
@@ -249,66 +258,11 @@ module OpenHAB
|
|
249
258
|
Core::Rules::Registry.instance
|
250
259
|
end
|
251
260
|
|
252
|
-
#
|
253
|
-
# Fetches all items from the item registry
|
254
|
-
#
|
255
|
-
# @return [Core::Items::Registry]
|
256
|
-
#
|
257
|
-
# The examples all assume the following items exist.
|
258
|
-
#
|
259
|
-
# ```xtend
|
260
|
-
# Dimmer DimmerTest "Test Dimmer"
|
261
|
-
# Switch SwitchTest "Test Switch"
|
262
|
-
# ```
|
263
|
-
#
|
264
|
-
# @example
|
265
|
-
# logger.info("Item Count: #{items.count}") # Item Count: 2
|
266
|
-
# logger.info("Items: #{items.map(&:label).sort.join(', ')}") # Items: Test Dimmer, Test Switch'
|
267
|
-
# logger.info("DimmerTest exists? #{items.key?('DimmerTest')}") # DimmerTest exists? true
|
268
|
-
# logger.info("StringTest exists? #{items.key?('StringTest')}") # StringTest exists? false
|
269
|
-
#
|
270
|
-
# @example
|
271
|
-
# rule 'Use dynamic item lookup to increase related dimmer brightness when switch is turned on' do
|
272
|
-
# changed SwitchTest, to: ON
|
273
|
-
# triggered { |item| items[item.name.gsub('Switch','Dimmer')].brighten(10) }
|
274
|
-
# end
|
275
|
-
#
|
276
|
-
# @example
|
277
|
-
# rule 'search for a suitable item' do
|
278
|
-
# on_load
|
279
|
-
# triggered do
|
280
|
-
# # Send ON to DimmerTest if it exists, otherwise send it to SwitchTest
|
281
|
-
# (items['DimmerTest'] || items['SwitchTest'])&.on
|
282
|
-
# end
|
283
|
-
# end
|
284
|
-
#
|
285
|
-
def items
|
286
|
-
Core::Items::Registry.instance
|
287
|
-
end
|
288
|
-
|
289
261
|
# @return [Core::Sitemaps::Provider]
|
290
262
|
def sitemaps
|
291
263
|
Core::Sitemaps::Provider.instance
|
292
264
|
end
|
293
265
|
|
294
|
-
#
|
295
|
-
# Get all things known to openHAB
|
296
|
-
#
|
297
|
-
# @return [Core::Things::Registry] all Thing objects known to openHAB
|
298
|
-
#
|
299
|
-
# @example
|
300
|
-
# things.each { |thing| logger.info("Thing: #{thing.uid}")}
|
301
|
-
# logger.info("Thing: #{things['astro:sun:home'].uid}")
|
302
|
-
# homie_things = things.select { |t| t.thing_type_uid == "mqtt:homie300" }
|
303
|
-
# zwave_things = things.select { |t| t.binding_id == "zwave" }
|
304
|
-
# homeseer_dimmers = zwave_things.select { |t| t.thing_type_uid.id == "homeseer_hswd200_00_000" }
|
305
|
-
# things['zwave:device:512:node90'].uid.bridge_ids # => ["512"]
|
306
|
-
# things['mqtt:topic:4'].uid.bridge_ids # => []
|
307
|
-
#
|
308
|
-
def things
|
309
|
-
Core::Things::Registry.instance
|
310
|
-
end
|
311
|
-
|
312
266
|
#
|
313
267
|
# Provides access to timers created by {after after}
|
314
268
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openhab-scripting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian O'Connell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-09-
|
13
|
+
date: 2024-09-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|