openhab-scripting 4.15.1 → 4.16.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/items/generic_item.rb +19 -0
- data/lib/openhab/dsl/things.rb +13 -4
- data/lib/openhab/version.rb +1 -1
- 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: f765fc75455c9aace6d355e897477c727dcdc7e826bb3b16824979c2cf882f56
|
4
|
+
data.tar.gz: cfb0262989931a22e637e1e2f625ca3f5256da37587d8400b10f68ece4b6c358
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99b0f1896dd66a599449dd96b061f38cc6ad92694bd9502bf14b5b6767330d8eebd714ea41536bb49f730a6fdb9c48e64a04b77c7cb9d54e72d61d617336c2d9
|
7
|
+
data.tar.gz: ff13507c8f80c3f7dbae3089d8ef322e0c0fbaccf835cdb80ea58ea4e595ac8e92b2e440cf4a2c8c2bf9c9401f9da7f98219857ed88ead80adbe853f3b2f2b76
|
@@ -131,6 +131,25 @@ module OpenHAB
|
|
131
131
|
group_names.map { |name| Groups.groups[name] }
|
132
132
|
end
|
133
133
|
|
134
|
+
# Return the item's thing if this item is linked with a thing. If an item is linked to more than one thing,
|
135
|
+
# this method only returns the first thing.
|
136
|
+
#
|
137
|
+
# @return [Thing] The thing associated with this item or nil
|
138
|
+
def thing
|
139
|
+
all_linked_things.first
|
140
|
+
end
|
141
|
+
alias linked_thing thing
|
142
|
+
|
143
|
+
# Returns all of the item's linked things.
|
144
|
+
#
|
145
|
+
# @return [Array] An array of things or an empty array
|
146
|
+
def things
|
147
|
+
registry = OpenHAB::Core::OSGI.service('org.openhab.core.thing.link.ItemChannelLinkRegistry')
|
148
|
+
channels = registry.get_bound_channels(name).to_a
|
149
|
+
channels.map(&:thing_uid).uniq.map { |tuid| Object.things[tuid] }
|
150
|
+
end
|
151
|
+
alias all_linked_things things
|
152
|
+
|
134
153
|
#
|
135
154
|
# Check equality without type conversion
|
136
155
|
#
|
data/lib/openhab/dsl/things.rb
CHANGED
@@ -83,11 +83,11 @@ module OpenHAB
|
|
83
83
|
include LazyArray
|
84
84
|
include Singleton
|
85
85
|
|
86
|
-
# Gets a specific thing by name in the format binding_id:type_id:thing_id
|
87
|
-
# @return Thing specified by name or nil if name does not exist in thing registry
|
86
|
+
# Gets a specific thing by name in the format binding_id:type_id:thing_id or via the ThingUID
|
87
|
+
# @return Thing specified by name/UID or nil if name/UID does not exist in thing registry
|
88
88
|
def [](uid)
|
89
|
-
|
90
|
-
thing = $things.get(
|
89
|
+
uid = generate_thing_uid(uid) unless uid.is_a?(org.openhab.core.thing.ThingUID)
|
90
|
+
thing = $things.get(uid) # rubocop: disable Style/GlobalVars
|
91
91
|
return unless thing
|
92
92
|
|
93
93
|
logger.trace("Retrieved Thing(#{thing}) from registry for uid: #{uid}")
|
@@ -100,6 +100,15 @@ module OpenHAB
|
|
100
100
|
def to_a
|
101
101
|
$things.getAll.map { |thing| Thing.new(thing) } # rubocop: disable Style/GlobalVars
|
102
102
|
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
# Returns a ThingUID given a string like object
|
107
|
+
#
|
108
|
+
# @return ThingUID generated by given name
|
109
|
+
def generate_thing_uid(uid)
|
110
|
+
org.openhab.core.thing.ThingUID.new(*uid.split(':'))
|
111
|
+
end
|
103
112
|
end
|
104
113
|
|
105
114
|
#
|
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.16.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-11-
|
11
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|