I have been using OH4 for some time so have my UoM pretty much sorted (I think). I have however just run into a weird issue with displayState that I do not recall seeing before.
The symptom is that occasionally the value for displayState becomes undefined.
As a test I have created a dummy item as follows:
label: ZZ Test display State
type: Number:Frequency
category: ""
groupNames: []
groupType: None
function: null
tags: []
with Metadata as follows:
Unit: Hz
State Description: %.1f Hz
Which from my understanding and past experience should display the item with a single decimal place, as follows:
I’ve never used the API explorer to set values, does it allow you to pass the UoM to the item at the same time as the value?
Are you able to try any of the above tests with the real item that has it’s value updated from a thing channel that (I assume) passes the UoM too? What sort of thing is the real item linked to? Which binding, etc?
That won’t work. d mean integer. You can’t have an integer with a decimal place.
Show the actual YAML of your Item and State Description metadata.
Do you see anything in openhab.log when it’s showing undefined?
If it’s a 16 bit integer, how are you ever getting values with decimal places at all? Are you applying a transform or the gain profile or something like that? Note that you can add units using the modbus gain profile according to the docs.
This has been true since the beginning of MainUI. In order to optimize the amount data being set to widgets, the displayState for an item will only ever be defined if it is different from the actual state. The devs decided it would be too resource intensive to send redundant data like that.
Take a look at the pre-fabbed widget code that pops up when you start a new widget:
Something like this is always necessary if you want the display state because this data optimization means that there are virtually guaranteed to be times when the display state is undefined.
(the @ widget expression operator does the same thing as the above code for the same reason).