Skip to content

Commit

Permalink
Drop openHAB 4.0 snapshot compatibility
Browse files Browse the repository at this point in the history
SemanticTags.add was only in core for a short time, and not during
any full release

Signed-off-by: Cody Cutrer <[email protected]>
  • Loading branch information
ccutrer committed Sep 8, 2023
1 parent 3ed2192 commit d07c584
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions lib/openhab/core/items/semantics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,25 +311,16 @@ def add(label: nil, synonyms: "", description: "", **tags)
synonyms = Array.wrap(synonyms).map { |s| s.to_s.strip }

tags.map do |name, parent|
# @deprecated OH4.0.0.M4 missing registry
if Provider.registry
parent = lookup(parent) unless parent.is_a?(SemanticTag)
next if lookup(name)
next unless parent

new_tag = org.openhab.core.semantics.SemanticTagImpl.new("#{parent.uid}_#{name}",
label,
description,
synonyms)
Provider.instance.add(new_tag)
lookup(name)
else
parent_is_tag = parent.respond_to?(:java_class) && parent.java_class < Tag.java_class
parent = parent_is_tag ? parent.java_class : parent.to_s
org.openhab.core.semantics.SemanticTags
.add(name.to_s, parent, label, synonyms.join(","), description)
&.then { lookup(name) }
end
parent = lookup(parent) unless parent.is_a?(SemanticTag)
next if lookup(name)
next unless parent

new_tag = org.openhab.core.semantics.SemanticTagImpl.new("#{parent.uid}_#{name}",
label,
description,
synonyms)
Provider.instance.add(new_tag)
lookup(name)
end.compact
end
end
Expand Down

0 comments on commit d07c584

Please sign in to comment.