diff --git a/src/entity-name.ts b/src/entity-name.ts index 5302403..ef676ca 100644 --- a/src/entity-name.ts +++ b/src/entity-name.ts @@ -12,6 +12,12 @@ function atLeastVersion(hass: HomeAssistant, major: number, minor: number): bool } function supportsEntityNames(hass: HomeAssistant): boolean { + // A hass can report a recent version without carrying the helper (a test + // harness, or a hass that has not finished initialising), and calling it + // then throws - so the version gate alone is not enough. + if (!hass || typeof (hass as { formatEntityName?: unknown }).formatEntityName !== 'function') { + return false; + } return atLeastVersion(hass, 2026, 4); }