Refinement of "State Description Pattern"

  • Platform information:
    • openHAB version: 4.2.0
  • Issue of the topic:
    I have an item of type: “Number:Power”.
    When using this item to feed some widgets, the number shown provides 2 digits decimal places precision.
    I would like to redefine its representation and found the “State Description Pattern” in the GUI, see below.
    But the “State Description Pattern” does not seem to be editable. (and I would have expected zero decimal places)
    What is best practice to convert the e.g. “30.00 W” to integer type “30 W” or single decimal place “30.0 W”?
    Inline transformation?

I assume you are running 4.2 M1? Especially when running unreleased versions of OH it’s important to state which milestone you are running or which snapshot you are running.

I haven’t followed the implementation of this very closely yet but I don’t think that particular field is fully implemented. Keep an eye on the PRs and issues in github.

In the mean time, click “Add Metadata” and add the Item metadata there.

I’m running openHAB 4.2.0 with Build #3974. (It’s an openHABian installation.)
Which metadata provides capabilities to change decimal places?

State Description

%.0f %unit%

The build you have running should have the changes to the unit UI included.

The UI shows the default state description pattern (%.0f %unit%) when none is set. When that is not changed, it is not saved.
Did you try changing it to e.g. %.1f %unit%? Could you remove the State Description metadata again and try setting it? Did the metadata State Description get created? If that works, the issue may be that the default state description is not used at all in Main UI.

1 Like

I find it shows %.0f %unit% even when the State Description one is set.

For example:

I have a temperature Item withe a State Description Pattern: %.1f °F

I can see it’s applied.

But the “State description pattern” on the Item’s edit page still reads %.0f %unit%.

When I try to change it it does not appear to save the change (in this case to %.3f %unit%).

If I go to an Item that does not have a State Description Pattern, when I go to the Item’s edit page when I change the State Description Pattern, upon hitting save it reverts back to %.0f %unit% and no State Description Metadata is created.

There are not errors in openhab.log. I’m running 4.2 M1.

Should I file an issue? I just assumed there was a PR not yet merged before the M1 release.

Yes, please. This is a bug. Something is wrong when it does not get updated.

Hmmm, this may be more widespread than just that one field.

I just tried to create a Thing and change the UID before saving it and it always reverts to the default once I click off the field. Interestingly even though it appears to revert on the page it took what I typed as the actual Thing ID.

I’ll create two issues and link them in case they are not related.

Stay tuned!

See State Description Pattern from Item's Edit Page not Saving · Issue #2468 · openhab/openhab-webui · GitHub and Changing Thing UID reverts to default · Issue #2469 · openhab/openhab-webui · GitHub