Humidity and Sitemap graph

I have a problem and I cannot found solutions in old posts.
I have a sitemaps with humidity. After upgrade to Openhab 4 I had “Err” on display sitemaps and after that I’ve updated all items with Number:Dimensionless and Point: Humidity.

After thatodification, I can see values on sitemaps but graphs shown data as decimal value, such as this picture.

There is a way to fix it?

Thanks in advance

Add % as unit (via metadata)

I already have as state description %.0f %% and I see right value, but graph in sitemap doesn’t show right values

Yes, adding the unit should fix it

How can I add unit by metadata? This item are linked to mqtt and values are set with % directly from thing

For UI defined items:

Open the item, click on metadata, click on unit

If the item is based on mqtt thing and has number: dimensionless type, the unit from mqtt is not forwarded to the item. Already had the same issue.


Your solution to @AnDuR’s problem is correct, but this part of the explanation isn’t quite right.

If set on the MQTT Channel, the unit is forwarded to the Item. However, if the unit metadata is not set on the Item, the system default unit is used for the Item’s state. And the system default for Number:Dimensionless is ONE, not %.

Therefore, if you’ve configured % in the MQTT Channel, that 27 % gets converted to 0.27 ONE as the Item’s state. The state description will convert that 0.27 ONE back to 27 % when it shows you the Item’s state in MainUI, but the Item’s state, and therefore what gets saved to persistence and charted, will still be 0.27.

Note that this is true for all units and all bindings. If the unit sent by the Channel doesn’t match the unit of the Item, the value gets converted to the unit of the Item. If there isn’t unit metadata explicitly set on the Item, the system default for that unit type is used.

My mqtt channel is configured as:

- id: umidity
    channelTypeUID: mqtt:number
    label: Umidita
    description: ""
      stateTopic: tele/collarmele/stufa/SENSOR
      transformationPattern: REGEX:(.*\"Humidity\".*)∩JSONPATH:$.SHT3X.Humidity
      unit: "%