Skip to content

Commit

Permalink
fix mired detection in OH 4.3 (#359)
Browse files Browse the repository at this point in the history
the unit symbol 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 <cody@cutrer.us>
  • Loading branch information
ccutrer authored Nov 25, 2024
1 parent 7db60f9 commit 94b0c2c
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 94b0c2c

Please sign in to comment.