Number pattern in Custom Widgets

Hi,

I am still struggling with the new possibilities in OH3 especially with pages and hence have a number of questions.
But first things first:
I have set a number patterns for my temperature items as metadata. Some are set to %.1f and one is set to %.1f°.
When I now add these items to a page, using a oh-list-card they appear as expected:
image

But I want to build more around this and are playing around with custom widgets. This is as far as I got now:
image

Here the code:

uid: Temperature_list
tags:
  - weather
  - list
props:
  parameters:
    - context: item
      description: An item to control
      label: Item
      name: item
      required: false
      type: TEXT
  parameterGroups: []
timestamp: Jan 10, 2022, 10:12:19 AM
component: f7-card
config:
  title: Wetter
slots:
  default:
    - component: f7-row
      slots:
        default:
          - component: f7-col
            config:
              style:
                font-size: 20px
                padding-left: 20px
            slots:
              default:
                - component: Label
                  config:
                    text: '="Aussentemperatur: "+items.Temp_Aussen.state'
                - component: Label
                  config:
                    text: '="Wohnzimmer: "+items.Temp_Ebene1.state'
                - component: Label
                  config:
                    text: '="Schlafzimmer: "+items.Temp_Ebene3.state'
                - component: Label
                  config:
                    text: '="Nebengebäude: "+items.Temp_NG.state'
                - component: Label
                  config:
                    text: '="Wassertemp.: "+items.PT_temp.state'


Why is the number pattern different?

Thanks for your help.

Pattern is not applied to raw state.
Pattern is used to format displayState

2 Likes

Perfect, thanks!

One more question if I may?
Is it possible to also define a pattern within the widget?
For example I have an item which holds a date, but I would like to show the weekday only.

EDIT: realised this now with:

text: =dayjs(items.fc_ObservationTime1.state).format('dddd')