Skip to content

Commit

Permalink
fix mired detection in OH 4.3
Browse files Browse the repository at this point in the history
the default unit for it changed, and aliases were added, so we need to
make sure to parse it first, and then compare against the actual constant
for it

Signed-off-by: Cody Cutrer <[email protected]>
  • Loading branch information
ccutrer committed Nov 25, 2024
1 parent 2cf93a7 commit 42a382d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/openhab/dsl/items/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,9 @@ def expire(*args, command: nil, state: nil, ignore_state_updates: nil, ignore_co
def unit=(unit)
@unit = unit

self.dimension ||= "Temperature" if unit&.to_s == "mired"
self.dimension ||= unit && org.openhab.core.types.util.UnitUtils.parse_unit(unit)&.then do |u|
org.openhab.core.types.util.UnitUtils.get_dimension_name(u)
if (openhab_unit = unit && org.openhab.core.types.util.UnitUtils.parse_unit(unit))
self.dimension ||= "Temperature" if openhab_unit == Units::MIRED
self.dimension ||= org.openhab.core.types.util.UnitUtils.get_dimension_name(openhab_unit)
end
self.format ||= unit && (if Gem::Version.new(Core::VERSION) >= Gem::Version.new("4.0.0.M3")
"%s %unit%"
Expand Down

0 comments on commit 42a382d

Please sign in to comment.