OH3 UI - Problem with number format

Hi everyone! I am an newbie with Openhab in general and installed OH3 Docker image last week. I already configured a few bindings (Daikin air condition and mobdus binding for reading values from my Heliotherm heatpump). This all works well. I was able to convert the modbus values in the binding with help of divideby10.js example and see the correct value in the Items overview (including unit of temperature. When I now configure a page I see in the widget e.g. 22,3 °C for the values from the Daikin binding but it shows me e.g. 1 (which is displayed as 1°C on the items page) for the modbus binding (it is somehow rounding it to full digits and excludes the unit of that value.
I configured so far everything via the GUI.
Any idea what could be the problem?

Pages Page:

And here a screenshot from the items page:

There is no real problem here beyond the fact that some bindings preview more hints for how to display Items states and others do not. You can fully customize how the Item’s states are displayed by editing the State Format metadata in the Item. Beyond that you can have full control over how the Item is displayed by adding custom widget metadata. The widget displayed at the top of the Item is the card widget.

I have a similar question. I understood that i can add metadata to items to influence how they are displayed in the widgets.

I have two items (one temperature and one humidity) from the same sensor implemented in the same way how those numbers end up in the items and the temperature is displayed as for example 11,6 (comma) and the humidity with 40.6 (point).

Now i can add Metadata to the temperature to get the correct format and unit, but with the humidity, i can’t do this because “%.1f %%” on a value with a point instead of a comma in between ends up interpreted as 4060,0%.

Can anybody point me in the right direction why my humidity is displayed as it is?

items list |grep Keller
humidity_keller (Type=NumberItem, State=37.9, Label=Feuchte Keller, Category=Humidity)
tmp_keller (Type=NumberItem, State=11.9 °C, Label=Temperatur Keller, Category=temperature)

You might be interested in -

Modbus binding has no idea how to deal with C, kW etc. units as they do not exist in modbus registers, these are just numbers.
There is more than one way to add units manually to your data and pass to a Quantity aware Item type - if you are already using a JS transform in your Modbus data Thing it is probably easiest there.

To control display of units and decimals, you need to look at your Item metadata / stateDescription / Pattern, and use something like %.1f %unit%

1 Like

I think i understood now that this calculation is performed by “Units Of Measurement” and hasn’t necessarily to do with the point/comma thing:

But how can i make the item know, that its value is already in “percent”???

When i simply add +"%" while writing to the item it seem to work, but then the Charts are “wrong” (0-1) :roll_eyes:

Quantity values of type Dimensionless can be a bit quirky.
Dimensionless does have units - it’s about ratios, so units % percentage and dB decibels can be used.
There is also the default unit, “1”, for a simple ration like 4:1, four-to-one.

So if you send say a Number:Dimensionless type Item a Quantity that gets interpreted as just “50”, that will be accepted as 50:1.
If you then display the same value but request in % units, you will see 50000%

So maybe this is going wrong. How are you doing this ‘writing’? What does your events.log show gets loaded into the Item state? How are you adding “%”, should you try +" %" with a space?

It might be a charting problem - do you get the other numeric displays you might expect?

Charts are quite likely to mess up in some editing situations, because persistence does not like it at all if you change an Item type after you have already started persisting it. That apply here?

Thanks for your reply.

The events.log shows the following:

2021-01-08 09:35:04.539 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘humidity_keller’ changed from 37.5 to 37.6
2021-01-08 09:45:02.023 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘tmp_keller’ changed from 11.2 °C to 11.3 °C

The “writing” to those items happens in the following rule:

rule "Kellerklima"
    Time cron "0 0/5 * * * ?"
    var TempHumid = executeCommandLine(Duration.ofSeconds(15), "/etc/openhab/scripts/rasp_keller_all.sh").split(" ")
    if (TempHumid.length == 2) { // Bsp: [17.0, 58.9] == 2 ggü [] == 1

So there is basically written a string to that number item, which can be extended via + “%”, then the unit is also written to the item and can be seen in the events.log as well as the temperature:

var TempHumid = executeCommandLine(Duration.ofSeconds(15), "/etc/openhab/scripts/rasp_keller_all.sh").split(" ")
DebugItem.postUpdate(TempHumid.get(1) + "%")

2021-01-08 10:18:58.601 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘DebugItem’ changed from 37.6 % to 37.7 %

And with the following pattern:

this results in:

But i tested this in a debugItem which changed its type some times, so maybe there is only a chart issue left? Now i’m back at home and can do some more testing to it.

1 Like

i created a new item, wrote to it like the debugItem in my post before but sadly everything looks the same… in a chart it shows 0.38% instead of 38%.

I think the item is good so far as i can see in the events.log but the graph isn’t. Any further idea?

Edit: i found the same question here: Charts in OH3 - #27 by VPrimus

Edit2: The solution is, not to use %unit% but hardcode it to “%%” - Then the chart is correct.

Thanks anyway for getting me through this!

1 Like

Does anyone know how to change the number format from US to German in the OH3 Chart? Example:
I would like to have a “comma” as separator for the value in the chart:

Also the values in the y-axis are shown in the us-number format:

ECharts doesn’t seem to play nice with locales & number formats (it can be passed a locale but it’s only for some text translations apparently), while it’s still possible to define formatter functions for everything, since they’re functions, it’s a no-no in YAML. So for now… no.


If it doesn’t do locales etc can we default it “manually” to ISO instead of mm/dd format when displaying the x-axis of the analyse graph?
Perhaps have it as a setting in the regional settings advanced?
Just a suggestion…