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

@@ -1,6 +1,6 @@
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { UNAVAILABLE, UNAVAILABLE_STATES } from "../../../data/entity";
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
import { TextEntity, setValue } from "../../../data/text";
import { HomeAssistant } from "../../../types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
@@ -71,7 +71,7 @@ class HuiTextEntityRow extends LitElement implements LovelaceRow {
const newValue = ev.target.value;
// Filter out invalid text states
if (newValue && UNAVAILABLE_STATES.includes(newValue)) {
if (newValue && isUnavailableState(newValue)) {
ev.target.value = stateObj.state;
return;
}