From 363ad369fc686671fe3b602416246f7d325c2a06 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Tue, 24 Jan 2023 17:55:13 +0100 Subject: [PATCH] Fix current_humidity no shown on climate state card if also current_temperature is set (#14993) * Also show current_humidity on climate * Use one line * Update src/components/ha-climate-state.ts Co-authored-by: Paul Bottein * Another blank and add import Co-authored-by: Paul Bottein --- src/components/ha-climate-state.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/ha-climate-state.ts b/src/components/ha-climate-state.ts index 9443352fb5..c4264f947b 100644 --- a/src/components/ha-climate-state.ts +++ b/src/components/ha-climate-state.ts @@ -3,6 +3,7 @@ import { customElement, property } from "lit/decorators"; import { computeAttributeValueDisplay } from "../common/entity/compute_attribute_display"; import { computeStateDisplay } from "../common/entity/compute_state_display"; import { formatNumber } from "../common/number/format_number"; +import { blankBeforePercent } from "../common/translations/blank_before_percent"; import { ClimateEntity, CLIMATE_PRESET_NONE } from "../data/climate"; import { isUnavailableState } from "../data/entity"; import type { HomeAssistant } from "../types"; @@ -47,6 +48,19 @@ class HaClimateState extends LitElement { if (!this.hass || !this.stateObj) { return undefined; } + if ( + this.stateObj.attributes.current_temperature != null && + this.stateObj.attributes.current_humidity != null + ) { + return `${formatNumber( + this.stateObj.attributes.current_temperature, + this.hass.locale + )} ${this.hass.config.unit_system.temperature}/ + ${formatNumber( + this.stateObj.attributes.current_humidity, + this.hass.locale + )}${blankBeforePercent(this.hass.locale)}%`; + } if (this.stateObj.attributes.current_temperature != null) { return `${formatNumber( @@ -59,7 +73,7 @@ class HaClimateState extends LitElement { return `${formatNumber( this.stateObj.attributes.current_humidity, this.hass.locale - )} %`; + )}${blankBeforePercent(this.hass.locale)}%`; } return undefined;