Anzeige von Temperaturen

Einrichtung der openHAB Umgebung und allgemeine Konfigurationsthemen.

Moderatoren: seppy, udo1toni

HappyDexter
Beiträge: 36
Registriert: 17. Sep 2020 15:03
Answers: 0

Re: Anzeige von Temperaturen

Beitrag von HappyDexter »

OK, habe das Problem gefunden und über ein Workaround gelöst.

Habe in einem anderen Forum folgenden Text gefunden:
displayState will not be present if it has the same value as state, please check
Also wird displayState nur ausgegeben, wenn displayState unterschiedlich zum state ist. Im Normalfall ist es ja nicht so, also sehe ich "undefined". Ich habe den Pattern jetzt einfach mal auf eine Nachkommastelle gekürzt und dann geht es mit displayState. Für die Temperatur reicht mir ja eigentlich eine Nachkommastelle. Jetzt muss ich nur hoffen, dass die zweite Nachkommastelle nie 0 wird, denn dann wird sie wohl weggelassen und ich würde wieder "undefined" bekommen.

Wäre es möglich in dem Widget zu prüfen ob die beiden identisch sind und wenn ja nur state auszugeben und wenn nicht displayState auszugeben?

Gruß
Happy

Benutzeravatar
peter-pan
Beiträge: 2758
Registriert: 28. Nov 2018 12:03
Answers: 30
Wohnort: Schwäbisch Gmünd

Re: Anzeige von Temperaturen

Beitrag von peter-pan »

Es gibt schon solche "Konstrukte"

Code: Alles auswählen

=(items[props.tl_item].displayState) || (items[props.tl_item].state)
aber in diesem Widget wird wohl darauf verzichtet, da man die Messeinheit als Suffix anhängen kann. Hast du unterschiedliche Item-Typen also Number oder Number:Temperature ?
Pi5/8GB(PiOS Lite 64-bit(bookworm)/SSD 120GB - OH4.3.5 openhabian

HappyDexter
Beiträge: 36
Registriert: 17. Sep 2020 15:03
Answers: 0

Re: Anzeige von Temperaturen

Beitrag von HappyDexter »

peter-pan hat geschrieben: 18. Dez 2024 17:37 Es gibt schon solche "Konstrukte"

Code: Alles auswählen

=(items[props.tl_item].displayState) || (items[props.tl_item].state)
aber in diesem Widget wird wohl darauf verzichtet, da man die Messeinheit als Suffix anhängen kann. Hast du unterschiedliche Item-Typen also Number oder Number:Temperature ?
Mit so einem Code habe ich es versucht, das hat aber nicht funktioniert. Jetzt habe ich folgenden Code und der scheint zu gehen:
label: = items[props.tmp_item].displayState ?
(items[props.tmp_item].displayState):(items[props.tmp_item].state)
Habe die Suffix Geschichte komplett rausgeschmissen!

Benutzeravatar
peter-pan
Beiträge: 2758
Registriert: 28. Nov 2018 12:03
Answers: 30
Wohnort: Schwäbisch Gmünd

Re: Anzeige von Temperaturen

Beitrag von peter-pan »

...das wundert mich jetzt aber. Ist das was Neues. Nach meinem Kenntnisstand war bisher ein doppeltes Pipe-Symbol das Synonym für eine Oder-Verknüpfung. Da muss ich noch mal weiterlesen. Evtl. hängt es auch mit dem Pattern/Formater und/oder dem Item-Typ zusammen. Bin mir da auch unsicher.

Sorry... hab's verstanden. Du fragst explizit den Status ab. (Im Label-Feld). Aber auch wieder nicht ;)
Pi5/8GB(PiOS Lite 64-bit(bookworm)/SSD 120GB - OH4.3.5 openhabian

HappyDexter
Beiträge: 36
Registriert: 17. Sep 2020 15:03
Answers: 0

Re: Anzeige von Temperaturen

Beitrag von HappyDexter »

Wenn ich ehrlich bin, weiß ich nicht genau was ich da mache, habe mir das in einem englischen Forum zusammengereimt. Aber es funktioniert :-)
Es kann auch sein, das die doppelte Pipe funktioniert, da hatte ich das mit dem Suffix noch hinten dran. Vielleicht lag es auch noch da dran.

Benutzeravatar
peter-pan
Beiträge: 2758
Registriert: 28. Nov 2018 12:03
Answers: 30
Wohnort: Schwäbisch Gmünd

Re: Anzeige von Temperaturen

Beitrag von peter-pan »

Ich mach das auch nur mit "try and error". Aber ich hab mir mal das widget angeschaut und diesen Ausdruck eingearbeitet.

Code: Alles auswählen

  label: '= (props.tmp_label ? props.tmp_label + " " : "") +
    (items[props.tmp_item].displayState || items[props.tmp_item].state) + (props.tmp_suffix ? " " + props.tmp_suffix :
    "")'
Ergebnis:
ergebnis.jpg
Das UoM-Item sieht so aus:
uom-item.jpg
Vielleicht klappt's mit dieser Version.

Hier noch der ganze Yaml-Code:

Code: Alles auswählen

uid: z_testTemperatureHumidity
tags:
  - humidity
  - standalone
  - temperature
props:
  parameters:
    - description: Title of the cell.
      label: Title
      name: title
      required: true
      type: TEXT
      groupName: title
    - context: item
      description: The state of this item will be displayed as temperature.
      label: Temperature item
      name: tmp_item
      required: true
      type: TEXT
      groupName: items
    - context: item
      description: The state of this item will be displayed as humidity.
      label: Humidity item
      name: hum_item
      required: true
      type: TEXT
      groupName: items
    - context: item
      description: The display state of this item will be displayed as last update
        timestamp. Use an item with the timestamp as state and set the pattern
        of the "State Description" metadata to format the timestamp.
      label: Last update item
      name: update_item
      required: false
      type: TEXT
      groupName: items
    - description: Label to be displayed in front of the temperature.
      label: Temperature Label
      name: tmp_label
      required: false
      type: TEXT
      groupName: labels
    - description: Suffix to be displayed after the temperature.
      label: Temperature Suffix
      name: tmp_suffix
      required: false
      type: TEXT
      groupName: labels
    - description: Label to be displayed in front of the humidity.
      label: Humidity Label
      name: hum_label
      required: false
      type: TEXT
      groupName: labels
    - description: Suffix to be displayed after the humidity.
      label: Humidity Suffix
      name: hum_suffix
      required: false
      type: TEXT
      groupName: labels
    - description: Label to be displayed in front of the last update timestamp.
      label: Last Update Label
      name: update_label
      required: false
      type: TEXT
      groupName: labels
  parameterGroups:
    - name: title
      label: Title
    - name: items
      label: Items
    - name: labels
      label: Labels
timestamp: Dec 18, 2024, 7:47:19 PM
component: oh-label-cell
config:
  action: analyzer
  actionAnalyzerItems: =[props.hum_item, props.tmp_item]
  expandable: false
  footer: '= (props.update_item ? (props.update_label ? props.update_label :
    "")  + " " + items[props.update_item].displayState : "")'
  header: = props.title
  icon: oh:temperature
  label: '= (props.tmp_label ? props.tmp_label + " " : "") +
    (items[props.tmp_item].displayState || items[props.tmp_item].state)  + (props.tmp_suffix ? " " + props.tmp_suffix :
    "")'
  subtitle: '= (props.hum_label ? props.hum_label + " " : "") +
    items[props.hum_item].state + (props.hum_suffix ? " " + props.hum_suffix :
    "")'
  trendItem: = props.tmp_item
Den Namen der uid des widgets kannst du ja selbst anpassen.
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
Pi5/8GB(PiOS Lite 64-bit(bookworm)/SSD 120GB - OH4.3.5 openhabian

HappyDexter
Beiträge: 36
Registriert: 17. Sep 2020 15:03
Answers: 0

Re: Anzeige von Temperaturen

Beitrag von HappyDexter »

Dank Dir Peter-Pan, hab Deine Variante jetzt eingebaut und funktioniert einwandfrei. Habe das Ganze im subtitel für die Humidity noch zusätzlich angepasst.

Code: Alles auswählen

uid: TemperatureHumidity
tags:
  - humidity
  - standalone
  - temperature
props:
  parameters:
    - description: Title of the cell.
      label: Title
      name: title
      required: true
      type: TEXT
      groupName: title
    - context: item
      description: The state of this item will be displayed as temperature.
      label: Temperature item
      name: tmp_item
      required: true
      type: TEXT
      groupName: items
    - context: item
      description: The state of this item will be displayed as humidity.
      label: Humidity item
      name: hum_item
      required: true
      type: TEXT
      groupName: items
    - context: item
      description: The display state of this item will be displayed as last update
        timestamp. Use an item with the timestamp as state and set the pattern
        of the "State Description" metadata to format the timestamp.
      label: Last update item
      name: update_item
      required: false
      type: TEXT
      groupName: items
    - description: Label to be displayed in front of the temperature.
      label: Temperature Label
      name: tmp_label
      required: false
      type: TEXT
      groupName: labels
    - description: Suffix to be displayed after the temperature.
      label: Temperature Suffix
      name: tmp_suffix
      required: false
      type: TEXT
      groupName: labels
    - description: Label to be displayed in front of the humidity.
      label: Humidity Label
      name: hum_label
      required: false
      type: TEXT
      groupName: labels
    - description: Suffix to be displayed after the humidity.
      label: Humidity Suffix
      name: hum_suffix
      required: false
      type: TEXT
      groupName: labels
    - description: Label to be displayed in front of the last update timestamp.
      label: Last Update Label
      name: update_label
      required: false
      type: TEXT
      groupName: labels
  parameterGroups:
    - name: title
      label: Title
    - name: items
      label: Items
    - name: labels
      label: Labels
timestamp: Dec 19, 2024, 9:01:40 AM
component: oh-label-cell
config:
  action: analyzer
  actionAnalyzerItems: =[props.hum_item, props.tmp_item]
  expandable: false
  footer: '= (props.update_item ? (props.update_label ? props.update_label :
    "")  + " " + items[props.update_item].displayState : "")'
  header: = props.title
  icon: oh:temperature
  label: '= (props.tmp_label ? props.tmp_label + " " : "") +
    (items[props.tmp_item].displayState || items[props.tmp_item].state)  +
    (props.tmp_suffix ? " " + props.tmp_suffix : "")'
  subtitle: '= (props.hum_label ? props.hum_label + " " : "") +
    (items[props.hum_item].displayState || items[props.hum_item].state)  +
    (props.hum_suffix ? " " + props.hum_suffix : "")'
  trendItem: = props.tmp_item

Benutzeravatar
peter-pan
Beiträge: 2758
Registriert: 28. Nov 2018 12:03
Answers: 30
Wohnort: Schwäbisch Gmünd

Re: Anzeige von Temperaturen

Beitrag von peter-pan »

Super ! 👍 . Und schon hast du dein eigenes Custom-Widget erstellt.
Viel Spass, weiterhin.
Pi5/8GB(PiOS Lite 64-bit(bookworm)/SSD 120GB - OH4.3.5 openhabian

Antworten