Layout of page in OH5 and formatting of labels

I try to display different labels and try to format the different labels. Reading some documentations it raises many questions. Don’t know if I should split them into different topics but let’s see.

  1. I create a new page. Once it is created as e.g Layout page, I cannot delete it nor change the layout. Perhaps I am missing the options for this, therefore my question: where to find the option for that? (I want to change it to responsive - if possible)
  2. I have a cell value like 585,000000 W, but want simply display it like 585 W. I’ve read about transformations in the meta data. I can add a cell and a Labeled Cell, but as soon I enter in the Yaml file Power [%.0f W] it will output the string only, without any formatting or replacing the value. Therefore the question : how to add a Label for which I can transform the values?

I do not think you can change between the different layout types once you have started to add components to the page (they require very different configurations which are not really compatible).

You have two options for deleting pages. The Help sidebar tells you how to delete pages from the Page list:

When you are editing a saved page, you can delete it (as well as change some other page settings) by clicking on the chevron in the bottom right next to the Run mode switch:
image
At the bottom of the panel that brings up is a Remove page link.

In this case, if you want formatting that is different from the default formatting of the items state, you will need to use widget expressions:

For something like a Label Cell, instead of setting the item property to the name of an item, you will need to put a widget expression in the label property of the cell. For that expression you can get just the numeric value of quantity state (by using the .numericState property) transform that value in whatever way you wish (in this case by applying the .toFixed(0) method to the value), and add the unit back in (using the .unit property).

There are lots of option to make that into a string for the label, but I would put that all together with a string template (use `...` instead of "...") like this:

label: =`${items.Your_Item_Name.numericState.toFixed(0)} ${items.Your_Item_Name.unit}`

For deleting the page I used the run mode. Honestly I would have never expected it there. But anyway, thank you for the hint.

Thanks as well for the link if the expressions and how to use it. Is there a way to figure out what properties an Item has? Like where to find that it has numeriValue or unit? In the provided link I didn’t find it (at the first glance). And on the UI I don’t know as well where to find it. In the Item section not…

When you are working in the widget expressions all Items are accessed using the items object. All Items will have a state property which returns the current state of the Item as a string regardless of the Item type. If the Item has state description metadata then there will also be a displayState property which gives the formatted state of the Item. Numeric Items will also have a numericState property which returns the state as a number and not a string. In addition to numericState Numeric Items with quantity states will also have a unit property. If at any point you are unsure, use the Code Tester tab in the developer panel. Put =items.Your_Item_Name in the code box and you will see the output object with its available properties.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.