I just migrated to openhab 3.3.0 from 3.2.0 and some item on my sitemap dropped there unit. That data are coming from mqtt and were saved as number. I have KM data, if I use number:length, it think it’s meters and if I format with km, I get 0 since it try to convert. Is there a way to tell him “hey, it’s km not m”?
Also, I have another number which is a %. I tried setting number, number:dimensionless but I cannot get it to display with a %. How do I do that?
For background;
MQTT channels do not usually add units to their updates for Items, but they can if you configure for that. So look there.
The result is that a channel may update with “50” or with “50%”.
If the update is “50%” you should link to a Number:Dimensionless type Item, that accepts “50%” with the unit.
If the update is “50” you would normally link to a Number type Item, no unit.
You can still configure the Item to format the display with XX so you would see “50XX” - or of course “50%”. It’s just a character for display, not a proper unit, and the Item state would still be just “50”.
You can also link update “50” with no unit to a Number:Dimensionless type Item - but then you must set a default unit for that Item, like % or km. Exactly how to do that depends on how you defined your Item, but its usually the ‘pattern’ part of Item metadata.
When a unit-less “50” updates this Item, the default unit will be used, and the Item state will “50%”.
Editing any of these small details in-flight may well not appear immediately.
I tried to add % but in the sitemap, it give ERR when I put a % in the label. I tried Number and Number:Dimensionless. Now it show with % and it’s as it was when I upgraded so I don’t know why it’s working.
The things are items are created in the GUI, but I don’t see any pattern. Here’s what I see. Image aren’t for these item but I have same option with the others.
Hello, maybe I can help you with my SoC items that I also get displayed in the sitemap.
I also had to try a bit and then it finally worked with the correct display format.
In any case, pattern must be in the state description of the item.
I’ll show you my configuration with a few screenshots.
In the first picture the characters [%.0f%%] in the item label name in the sitemap editor were entered there by OpenHab.
I don’t know why, but afterwards they disappeared in the widget.
Ah, the %% escape would have solved everything. I was putting label=“asdf %” and it didn’t liked having only % and I didn’t though about using a double %%.