From bbb64870a138e691bc4a555feb83c68311ac057c Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Mon, 22 Jul 2024 01:28:51 -0700 Subject: [PATCH] Leave climate humidity mode if entity stops supporting it (#21423) * Leave climate humidity mode if entity stops supporting it * check changedProps --- .../more-info/controls/more-info-climate.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/dialogs/more-info/controls/more-info-climate.ts b/src/dialogs/more-info/controls/more-info-climate.ts index 086bb7fa78..7b5e4190c0 100644 --- a/src/dialogs/more-info/controls/more-info-climate.ts +++ b/src/dialogs/more-info/controls/more-info-climate.ts @@ -6,7 +6,14 @@ import { mdiTuneVariant, mdiWaterPercent, } from "@mdi/js"; -import { CSSResultGroup, LitElement, css, html, nothing } from "lit"; +import { + CSSResultGroup, + LitElement, + PropertyValues, + css, + html, + nothing, +} from "lit"; import { property, state } from "lit/decorators"; import { stopPropagation } from "../../../common/dom/stop_propagation"; import { supportsFeature } from "../../../common/entity/supports-feature"; @@ -39,6 +46,17 @@ class MoreInfoClimate extends LitElement { @state() private _mainControl: MainControl = "temperature"; + protected willUpdate(changedProps: PropertyValues): void { + if ( + changedProps.has("stateObj") && + this.stateObj && + this._mainControl === "humidity" && + !supportsFeature(this.stateObj, ClimateEntityFeature.TARGET_HUMIDITY) + ) { + this._mainControl = "temperature"; + } + } + protected render() { if (!this.stateObj) { return nothing;