diff --git a/src/dialogs/more-info/controls/more-info-fan.ts b/src/dialogs/more-info/controls/more-info-fan.ts index 57a4dd81dd..96a3826cb5 100644 --- a/src/dialogs/more-info/controls/more-info-fan.ts +++ b/src/dialogs/more-info/controls/more-info-fan.ts @@ -1,19 +1,14 @@ import { - mdiCreation, mdiFan, mdiFanOff, mdiPower, mdiRotateLeft, mdiRotateRight, + mdiTuneVariant, } from "@mdi/js"; import { CSSResultGroup, LitElement, PropertyValues, html, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { stopPropagation } from "../../../common/dom/stop_propagation"; -import { - computeAttributeNameDisplay, - computeAttributeValueDisplay, -} from "../../../common/entity/compute_attribute_display"; -import { computeStateDisplay } from "../../../common/entity/compute_state_display"; import { stateActive } from "../../../common/entity/state_active"; import { supportsFeature } from "../../../common/entity/supports-feature"; import "../../../components/ha-attributes"; @@ -65,17 +60,15 @@ class MoreInfoFan extends LitElement { }); }; - _setReverseDirection() { - this.hass.callService("fan", "set_direction", { - entity_id: this.stateObj!.entity_id, - direction: "reverse", - }); - } + _handleDirection(ev) { + const newVal = ev.target.value; + const oldVal = this.stateObj?.attributes.direction; + + if (!newVal || oldVal === newVal) return; - _setForwardDirection() { this.hass.callService("fan", "set_direction", { entity_id: this.stateObj!.entity_id, - direction: "forward", + direction: newVal, }); } @@ -93,7 +86,7 @@ class MoreInfoFan extends LitElement { } _handleOscillating(ev) { - const newVal = ev.target.value === "yes"; + const newVal = ev.target.value === "on"; this.hass.callService("fan", "oscillate", { entity_id: this.stateObj!.entity_id, @@ -113,12 +106,8 @@ class MoreInfoFan extends LitElement { const forcedState = liveValue != null ? (liveValue ? "on" : "off") : undefined; - const stateDisplay = computeStateDisplay( - this.hass.localize, + const stateDisplay = this.hass.formatEntityState( this.stateObj!, - this.hass.locale, - this.hass.config, - this.hass.entities, forcedState ); @@ -186,49 +175,21 @@ class MoreInfoFan extends LitElement { .iconPathOff=${mdiFanOff} > `} - ${supportSpeedPercentage || supportsDirection - ? html`
` + ${supportSpeedPercentage + ? html` + + ` : nothing}