Seite 2 von 2

[GELÖST] Mehrzeiligen Text in Widget und Sitemap

Verfasst: 12. Nov 2022 00:09
von lenschith
habe heute im Forum ein Widget gefunden das genau das macht was ich möchte. Ich habe das Widget nochmal etwas angepasst jetzt kann man den Text der Unwetterwarnung endlich gut lesen.
Screenshot 2022-11-12 000604.png
Falls jemand Interesse hat, hier ist der Code:

Code: Alles auswählen

uid: Unwetter Card
tags:
  - dwd
  - unwetterwarnung
  - lenschi.th
props:
  parameters:
    - context: item
      description: Warnung Titel
      label: Headline
      name: headline
      required: true
      type: TEXT
    - context: item
      description: Warnung Type
      label: Type
      name: type
      required: true
      type: TEXT
    - context: item
      description: Warnung Schweregrad
      label: Severity
      name: severity
      required: true
      type: TEXT
    - context: item
      description: Warnung Gültig ab
      label: Valid from
      name: validFrom
      required: false
      type: TEXT
    - context: item
      description: Warnung Gültig bis
      label: Valid to
      name: validTo
      required: false
      type: TEXT
    - context: item
      description: Warnung Beschreibung
      label: Description
      name: description
      required: true
      type: TEXT
    - context: item
      description: Anweisung
      label: Instruction
      name: validTo
      required: false
      type: TEXT
  parameterGroups: []
timestamp: Nov 12, 2022, 12:02:45 AM
component: f7-card
config:
  style:
    noShadow: false
    border-radius: 5px
    box-shadow: 5px 5px 10px 1px rgba(0,0,0,0.1)
    class:
      - padding: 0px
    margin-left: 0px
    margin-right: 0px
  title: =items[props.headline].state
slots:
  content:
    - component: oh-list-card
      config:
        noBorder: true
        noShadow: true
        outline: true
      slots:
        default:
          - component: oh-list-item
            config:
              title: =items[props.type].state
              icon: '=items[props.severity].displayState === "Leicht" ? "f7:cloud_drizzle_fill" : items[props.severity].displayState === "Mittel" ? "f7:cloud_hail_fill" :items[props.severity].displayState === "Schwer" ? "f7:cloud_bolt_fill" :items[props.severity].displayState === "Extrem" ? "f7:cloud_bolt_rain_fill" : ""'
              iconColor: '=items[props.severity].displayState === "Leicht" ? "yellow" : items[props.severity].displayState === "Mittel" ? "violett" :items[props.severity].displayState === "Schwer" ? "orange" :items[props.severity].displayState === "Extrem" ? "red" : "black"'
              badgeColor: '=items[props.severity].displayState === "Leicht" ? "yellow" : items[props.severity].displayState === "Mittel" ? "violett" :items[props.severity].displayState === "Schwer" ? "orange" :items[props.severity].displayState === "Extrem" ? "red" : "black"'
              badge: =items[props.severity].displayState
          - component: oh-label-item
            config:
              icon: f7:clock
              iconColor: red
              title: "Gültig ab:"
              item: =props.validFrom
          - component: oh-label-item
            config:
              icon: f7:clock_fill
              iconColor: green
              title: "Gültig bis: "
              item: =props.validTo
    - component: f7-card
      config:
        noBorder: false
        noShadow: true
        outline: false
        content: =items[props.description].state
    - component: f7-card-footer
      slots:
        default:
          - component: Label
            config:
              text: =props.anweisung
              style:
                color: red
                text-align: center
                font-size: 15px
                font-weight: 800

Ursprünglich habe ich den Code hier gefunden: https://community.openhab.org/t/mainui- ... ide/133486

Gruß Lenschi

Re: [GELÖST] Mehrzeiligen Text in Widget und Sitemap

Verfasst: 12. Nov 2022 14:52
von udo1toni
Sehr schön. Wo kann ich als Nicht-Bier-Trinker meinen politisch korrekten Tee eintragen?

~SCNR~

Re: [GELÖST] Mehrzeiligen Text in Widget und Sitemap

Verfasst: 12. Nov 2022 23:48
von peter-pan
udo1toni hat geschrieben: 12. Nov 2022 14:52~SCNR~
...(ich auch nicht) Das ist der kleine Trick an der Sache. Das hier löschen ( mit der Entferntaste nicht mit Bier ;) )

Code: Alles auswählen

    - context: item
      description: Anweisung
      label: Instruction
      name: validTo
      required: false
      type: TEXT
und Ersetzen mit:

Code: Alles auswählen

    - description: Anweisung
      label: Instruction
      name: anweisung
      required: false
      type: TEXT
:lol: :lol: :lol:

...dann klappt's auch mit Tee

Re: [GELÖST] Mehrzeiligen Text in Widget und Sitemap

Verfasst: 13. Nov 2022 00:54
von lenschith
oh, da hab ich was übersehen danke ;)

Re: [GELÖST] Mehrzeiligen Text in Widget und Sitemap

Verfasst: 22. Jun 2023 21:08
von toto1975
Ist zwar schon ein wenig älter aber wie habt ihr die Felder "Valid From" und "Valid To" formatiert? Ich bekomme die Daten im Moment so angezeigt "2023-06-22T15:00:00.000+0200"

Danke für einen Tipp

Viele Grüße
Torsten

Re: [GELÖST] Mehrzeiligen Text in Widget und Sitemap

Verfasst: 23. Jun 2023 09:39
von peter-pan
Ich denke das liegt an der Formatierung des Items. Entweder im Text bei Items die in Textform erstellt sind (xxx.items). Oder in den Metadaten bei Items die mit der Main-UI erstellt worden sind.