UoM Number:Time s --> day with translation for day

In OH 4 the UoM Number:Time is now stored in seconds if I am not mistaken. I can convert the output for the item using UoM which is great by putting for example [%.0f day]. Is it possible to use this syntax but translate day to another language than English, i.e., Tage?

Seconds has always been the default.

You can change that by setting the unit metadata so that the Item stores something else.

I have no idea about the translation of the unit. If it doesn’t just happen I’d assume it’s not supported.

You can change the Item to be just a Number and use a transform profile to convert what ever units it’s receiving from the binding to days. and then the state description pattern won’t be dealing with units and you can put anything you want there.

Thanks, simply putting { ..., unit="day" } allows to put [%.0f Tage].

1 Like

Hi, I tried to follow up it because I have the same issue but it doesn’t work for me.

Fir I set the item metadata to unit day. Ok, now I see the number of days and not seconds. But I want use the German expression “Tage”.

But the tag “Tage” is not valid. I tried to add state description and add pattern with % Tage but it also doesn’t work.

Any idea what is wrong ?

In metadata you need to use day while Tage needs to be used in the display string.

I have made a lot of tries but it doesn’t work for me actual.

Item is defined with unit = day.

In the label widget I tried to add the label

          - component: oh-grid-col
            config: {}
                - component: oh-label-card
                    item: VW_maintenanceIntervalOilChange
                    title: Nächster Ölwechsel in Tagen
                    label: =(items.VW_maintenanceIntervalOilChange.state)+" Tage"

The result

I tried to use formular as number … and a lot of expression which I figure out. Nothing works.

The result what I want is that “102 Tage” will be shown but no clue how to eliminate the item unit.

could it be that this is the wrong place ?

I am using textual definitions with:

"Inspektion [%.0f Tage]"

If I’m right that you don’t use pages ?

I use oh 4.0.1 and a label widget. This works with Oh3.4.without problems. It’s a cosmetical problem but it would help to figure out how for other requirements.

As far as I understood you need to set unit metadata to day, but state description metadata to Tage

Yes, Unit is day because otherwise it will be displayed in seconds. But I want show the german unit text - Tage instead of day

Have you tried to add state description metadata? Something like “%.0f Tage” should be the pattern

1 Like

Yes, pattern doesn’t work.

Can you share your full item definition and item state / display state (retrievable via developer sidebar out rest API)

Many thanks for your reply.

This issue is solved now. Here the way and the mistakes from my end.

For the display in a page there are 2 options.

  1. Directly in the label setting of the label-widget. Result : In this case the unit is preserved, you can only add information.
  2. add the state description like Matze wrote. Result : It’s an overlay of the Unit and replace it.

My mistakes are that I dont’t restart the service to update the data (it’s for me the easiest way to update all data) and the second was that I forgot to remove the label value in the label-widget - in this case the state description will be ignored. To much tests in parallel can bring problems sometimes :slight_smile:

Many thanks to all of you for your help !

Unit is unit, affecting what the value really is.
Display pattern is something different, only for display.
No matter where it’s defined in state description options pattern, widget label or sitemap definition.