This widget is derived from the Temperature and humidity widget created by @debacher and adds additional configuration options. You can choose two separate items for temperature and humidity and optionally a third item for the last update timestamp. Labels and suffixes can be configured to adapt the widget to different languages or use none or shorter descriptions for better display on small mobile screens.
The full list of customization options is:
Title: title of the cell.
Temperature item: the state of this item will be displayed as temperature.
Humidity item: the state of this item will be displayed as humidity.
Last update item: 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.
Temperature Label: label to be displayed in front of the temperature.
Temperature Suffix: suffix to be displayed after the temperature.
Humidity Label: label to be displayed in front of the humidity.
Humidity Suffix: suffix to be displayed after the humidity.
Last Update Label: label to be displayed in front of the last update timestamp.
uid: TemperatureHumidity
tags:
- temperature
- humidity
- standalone
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: Jan 21, 2023, 5:07:58 AM
component: oh-label-cell
config:
header: '= props.title'
label: '= (props.tmp_label ? props.tmp_label + " " : "") + items[props.tmp_item].state + (props.tmp_suffix ? " " + props.tmp_suffix : "")'
trendItem: '= props.tmp_item'
action: analyzer
actionAnalyzerItems: =[props.hum_item, props.tmp_item]
icon: oh:temperature
subtitle: '= (props.hum_label ? props.hum_label + " " : "") + items[props.hum_item].state + (props.hum_suffix ? " " + props.hum_suffix : "")'
footer: '= (props.update_item ? (props.update_label ? props.update_label : "") + " " + items[props.update_item].displayState : "")'
expandable: false
Oh, thanks, did that now. I thought from the description in the template that first the post will be reviewed and then the published tag will be added by admins/moderators.
I manually added it to my instance and also made the hum_item optional (I had a few locations which do not have a humidity sensor but I want to keep the look and feel the same). you can find the adapted code below:
uid: TemperatureHumidity
tags:
- temperature
- humidity
- standalone
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: false
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: Sep 26, 2023, 7:19:38 PM
component: oh-label-cell
config:
header: = props.title
label: '= (props.tmp_label ? props.tmp_label + " " : "") + items[props.tmp_item].state + (props.tmp_suffix ? " " + props.tmp_suffix : "")'
trendItem: = props.tmp_item
action: analyzer
actionAnalyzerItems: "=props.hum_item ? [props.hum_item, props.tmp_item] : [props.tmp_item]"
icon: oh:temperature
subtitle: '= (props.hum_label ? props.hum_label + " " : "") + (props.hum_item ? items[props.hum_item].state : " ") + (props.hum_suffix ? " " + props.hum_suffix : "")'
footer: '= (props.update_item ? (props.update_label ? props.update_label : "") + " " + items[props.update_item].displayState : "")'
expandable: false
I used the Em Space from https://emptycharacter.com/ to make Openhab think there’s still something to display for the subtitle - this way the temperatures stays aligned
You can use any item that contains the last update time. Formatting is done via the state description of the item, the widget just takes what it gets from there.