Fix logbook reporting unknown states as unavailable (#14359)

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
This commit is contained in:
J. Nick Koston 2022-11-15 08:07:50 -06:00 committed by GitHub
parent 681c745e84
commit ae15dd678b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -10,7 +10,7 @@ import { computeStateDomain } from "../common/entity/compute_state_domain";
import { LocalizeFunc } from "../common/translations/localize";
import { HaEntityPickerEntityFilterFunc } from "../components/entity/ha-entity-picker";
import { HomeAssistant } from "../types";
import { UNAVAILABLE_STATES } from "./entity";
import { UNAVAILABLE, UNKNOWN } from "./entity";
const LOGBOOK_LOCALIZE_PATH = "ui.components.logbook.messages";
export const CONTINUOUS_DOMAINS = ["counter", "proximity", "sensor", "zone"];
@ -421,7 +421,11 @@ export const localizeStateMessage = (
return localize(`${LOGBOOK_LOCALIZE_PATH}.turned_off`);
}
if (UNAVAILABLE_STATES.includes(state)) {
if (state === UNKNOWN) {
return localize(`${LOGBOOK_LOCALIZE_PATH}.became_unknown`);
}
if (state === UNAVAILABLE) {
return localize(`${LOGBOOK_LOCALIZE_PATH}.became_unavailable`);
}

View File

@ -391,6 +391,7 @@
"turned_on": "turned on",
"changed_to_state": "changed to {state}",
"became_unavailable": "became unavailable",
"became_unknown": "became unknown",
"detected_tampering": "detected tampering",
"cleared_tampering": "cleared tampering"
}