Why to use units?

All,

Just a quick one:
I am currently migrating from 2.5-x to 3.0 and it works perfectly smooth with the new UI :slight_smile:
So, thanks a million to all the contributors!

Because I touch the system significantly anyway I wonder if I should change all Number items to use units (e.g. Number:Temperature).

I use some of these already, but struggeled a lot when it came to number comparison (temperature >= xx).

So the simple question is:
Is there any other advantage of using units globally other than I can save time not to manually put °C into Habpanel etc.? (which I already did)

Without the units comparisons are much easier.
Thanks in advance.

There can be in some cases.

Some devices output temperature, to use your example, in degrees Fahrenheit. Using units, Oh easily does the conversion. You can even have 2 different Items, one showing each unit.

Dimmers, many times, use a percentage. that can be useful too, in some cases.

if(MyTempItem.state >= 20 | °C)

It’s pretty nice to choose what ever units I want regardless of what units the sensor reports. I’m in the US so it’s nice but too have to convert the state of the item to °F to do math. It becomes even more useful with units like data size, energy measurements, and the like.

Only if everything is already in the same units though. Otherwise you have to normalize then yourself.

1 Like

Thanks Rich.

I already have a few of them and I am (still) hesitant about changing the others.
Especially because I have tons of OpenWeatherMap temperature items without units.

Maybe I did not see it because I don’t use Energy number items a lot.
But that’s a good point.

After I migrated to OH3, I started to use units (Number:Temperature, …:Dimensionless, etc).
However, I have one inconsistancy using these two Battery levels with Dimensionless.

This one:
Number:Dimensionless Ind_Humidity "Luftfeuchte [%.0f %unit%]"
shows correctly:

The same config on a battery:

Number:Dimensionless       Z_Bath_W_Batt        "Bad Fenster Batterie [%.0f %unit%]"

shows

When I change the Battery item to use this
[%d %%]
I get 6500 %.
Any idea what could be the reason for this behaviour?

Yes. Whatever updates this Item is sending just a number, “65”.
For the unusual case of Number:Dimensionless types, a “blank” unit is both acceptable and meaningful. “65” is taken to mean a ratio of 65-to-1 (see the “one” unit in your screenshot, this where it comes from).
When you ask the UI to display 65-to-1 in % units, that’s 6500%.

To continue to use a Number:Dimensionless Item type, you need whatever is updating it to supply units as well. If it’s a channel, you can use a transform profile to add a string like " %".

It looks like “whatever is updating it” might be zwave, so the real fix would be an update to zwave binding database to get this device’s battery channel with units. That might already have happened, but then you’d need to delete and recreate the Thing to pick up new properties I think?

1 Like

Thank you - that totally makes sense!
And you are right - all the problematic items are from zwave devices. :slight_smile:

I will see whether creating the things again or change the format.
Again, thanks for your quick help.