Ensure computeStateName returns a string type (#17928)

This commit is contained in:
karwosts 2023-09-25 09:11:02 -07:00 committed by GitHub
parent 22f9dbd65d
commit 362d950515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,7 @@ export const computeStateNameFromEntityAttributes = (
): string =>
attributes.friendly_name === undefined
? computeObjectId(entityId).replace(/_/g, " ")
: attributes.friendly_name || "";
: (attributes.friendly_name ?? "").toString();
export const computeStateName = (stateObj: HassEntity): string =>
computeStateNameFromEntityAttributes(stateObj.entity_id, stateObj.attributes);