Try specifying this in the ITEM label definition, giving OH a chance to figure out units before using them
or
Try [%.1f %%%] , so far as I can make out that is %unit% of % type.
For myself I have Number:Dimensionless CurrentHumidity "humidity [%d %unit%]" <humidity> { channel="openweathermap:weather-and-forecast:api:foss:current#humidity" }
but that is using input from a UoM aware binding, not a script.
Thanks for the leads. Unfortunately specifying this in the ITEM label definition will result in the Factor 100 conversion.
[%.1f %%%] results in an Err on the Sitemap.
A dirty workaround would be to divide the value by 100 prior to the usage. However I use the value directly from the item for another thing (through the REST API where I need it without a dimension). There I could potentially do the next dirty workaround and multiply it by 100 again … but quite frankly this would be a shame
The thing that bothers me is that I collect a second humidity value also from openweathermap.
I set it up exactly as you also described and everything works perfectly fine, but not with the humidity value that I get from my DHT22 sensor.
Maybe the fix should go in your rule, to make the Item understand it is being fed a percentage not a simple number.
From your logInfo, HUMID has a value of 46.10 and I think it will be a string “46.10” as it is the result of an exececuteCommandLine.
postUpdate likes to be fed strings, so we just add the UoM indicator to the string hum_ist.postUpdate(HUMID + "|%")
Your problem stemmed from your item definition:
It should have been:
Number:Dimensionless hum_ist "Luftfeuchtigkeit innen [%.1f %%]" <humidity>
And your sitemap:
Text item=hum_ist
The item definition label formatting would then instruct the UoM than we are using percents
I advise you to put your labels and formatting and icons ALL in the item definition and keep the sitemap as simple as possible.
This way there is only one file to maintain