From b99746e075baeffbeba63446f15ce1dd1a67a7ca Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Wed, 20 Nov 2024 16:03:49 -0700 Subject: [PATCH] fix mired detection in OH 4.3 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 --- lib/openhab/dsl/items/builder.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/openhab/dsl/items/builder.rb b/lib/openhab/dsl/items/builder.rb index d10e3bafc..6198fffb7 100644 --- a/lib/openhab/dsl/items/builder.rb +++ b/lib/openhab/dsl/items/builder.rb @@ -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 == org.openhab.core.library.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%"