Skip to content

Commit

Permalink
Leave climate humidity mode if entity stops supporting it (#21423)
Browse files Browse the repository at this point in the history
* Leave climate humidity mode if entity stops supporting it

* check changedProps
  • Loading branch information
karwosts authored Jul 22, 2024
1 parent f05ddd3 commit bbb6487
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/dialogs/more-info/controls/more-info-climate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bbb6487

Please sign in to comment.