Fix localize key type errors for states (#14691)

* Replace unavailable state checks with type predicate

* Remove localize exceptions related to state

* Use literal types for climate attributes

* Add fan action to climate tile badge

* Use literal types for truncated states in badges

* Use literal type for humidifier state

* Replace unavailable state checks in calendar and tile card

* Avoid string split for truncated key
This commit is contained in:
Steve Repsher
2022-12-14 13:39:10 -05:00
committed by GitHub
parent b4d6fc3c20
commit e8e4733fc9
41 changed files with 153 additions and 112 deletions

View File

@@ -8,7 +8,7 @@ import {
TemplateResult,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { UNAVAILABLE_STATES } from "../../../data/entity";
import { isUnavailableState } from "../../../data/entity";
import { canRun, ScriptEntity } from "../../../data/script";
import { HomeAssistant } from "../../../types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
@@ -65,7 +65,7 @@ class HuiScriptEntityRow extends LitElement implements LovelaceRow {
${stateObj.state === "off" || stateObj.attributes.max
? html`<mwc-button
@click=${this._runScript}
.disabled=${UNAVAILABLE_STATES.includes(stateObj.state) ||
.disabled=${isUnavailableState(stateObj.state) ||
!canRun(stateObj)}
>
${this._config.action_name ||