Guard against a hass without formatEntityName

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Bram Kragten
2026-09-15 12:33:10 +02:00
co-authored by Claude Opus 5
parent 547b34e85a
commit 64b83101dd
+6
View File
@@ -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);
}