Comparing degree celsius fails for values bigger than 10

Hi community,

I am calculating the dew point of rooms and compare them to the outside. It works well in rules and (old) sitemaps.
Since >1 year I have a page, where the dew points (Taupunkt) are compared and the icon state depends on the comparison to the outside dew point (Draußen).
The comparison works well, but when the room dew point is >= 10.0°C the comparison is always “false”.
This is not the case if a degree celsius value is measured (not calculated) by a sensor, e.g. outside temperature, and compared to a fixed value.

Does anybody know why?

...
- component: oh-label-item
                config:
                  action: analyzer
                  actionAnalyzerItems:
                    - BathroomOGTaupunkt
                  icon: '=(items.BathroomOGTaupunkt.state > items.OutsideTaupunkt.state) ?
                    "oh:lueften" : "oh:keinlueften"'
                  iconUseState: false
                  item: BathroomOGTaupunkt
                  title: Bad OG
              - component: oh-label-item
                config:
                  action: analyzer
                  actionAnalyzerItems:
                    - BedroomKidsTaupunkt
                  icon: '=(items.BedroomKidsTaupunkt.state > items.OutsideTaupunkt.state )?
                    "lueften" : "keinlueften"'
                  iconUseState: false
                  item: BedroomKidsTaupunkt
                  title: Schlafzimmer Kinder
              - component: oh-label-item
                config:
                  action: analyzer
                  actionAnalyzerItems:
                    - BedroomParentsTaupunkt
                  icon: '=(items.BedroomParentsTaupunkt.state > items.OutsideTaupunkt.state )?
                    "lueften" : "keinlueften"'
                  iconUseState: false
                  item: BedroomParentsTaupunkt
                  title: Schlafzimmer Eltern
              - component: oh-label-item
                config:
                  action: analyzer
                  actionAnalyzerItems:
                    - PlayroomTaupunkt
                  icon: '=(items.PlayroomTaupunkt.state > items.OutsideTaupunkt.state )? "lueften"
                    : "keinlueften"'
                  iconUseState: false
                  item: PlayroomTaupunkt
                  title: Spielzimmer
...

In widget expressions such as '=(items.BathroomOGTaupunkt.state > items.OutsideTaupunkt.state) ? "oh:lueften" : "oh:keinlueften"' the .state of an item is always a string. So you are not performing a numerical comparison, you are performing a string comparison and in that case the comparison goes character to character so '9' is greater the '10' because the code for the 9 character is greater than the code for the '1' character.

To get around this problem you want to use the numericState instead of the state. For example: items.BathroomOGTaupunkt.numericState returns a number value with the unit removed instead of a string. So the correct expression would be:

icon: '=(items.BathroomOGTaupunkt.numericState > items.OutsideTaupunkt.numericState) ? "oh:lueften" : "oh:keinlueften"'"oh:keinlueften"'

There’s a shorthand for numeric state

#'itemname'