Fix chart tooltip crash for disabled entity (#17767)

This commit is contained in:
karwosts 2023-09-01 02:36:43 -07:00 committed by GitHub
parent e98e59a265
commit 3917739ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,7 +108,7 @@ export const formatNumber = (
* @returns An `Intl.NumberFormatOptions` object with `maximumFractionDigits` set to 0, or `undefined`
*/
export const getNumberFormatOptions = (
entityState: HassEntity,
entityState?: HassEntity,
entity?: EntityRegistryDisplayEntry
): Intl.NumberFormatOptions | undefined => {
const precision = entity?.display_precision;
@ -119,8 +119,8 @@ export const getNumberFormatOptions = (
};
}
if (
Number.isInteger(Number(entityState.attributes?.step)) &&
Number.isInteger(Number(entityState.state))
Number.isInteger(Number(entityState?.attributes?.step)) &&
Number.isInteger(Number(entityState?.state))
) {
return { maximumFractionDigits: 0 };
}