diff --git a/lib/extension/homeassistant.ts b/lib/extension/homeassistant.ts index fa03042f37..2e6e0dd97d 100644 --- a/lib/extension/homeassistant.ts +++ b/lib/extension/homeassistant.ts @@ -1039,6 +1039,14 @@ export default class HomeAssistant extends Extension { throw new Error(`Unsupported exposes type: '${firstExpose.type}'`); } + // Exposes with category 'config' or 'diagnostic' are always added to the respective category. + // This takes precedence over definitions in this file. + if (firstExpose.category === 'config') { + discoveryEntries.forEach((d) => d.discovery_payload.entity_category = 'config'); + } else if (firstExpose.category === 'diagnostic') { + discoveryEntries.forEach((d) => d.discovery_payload.entity_category = 'diagnostic'); + } + discoveryEntries.forEach((d) => { // If a sensor has entity category `config`, then change // it to `diagnostic`. Sensors have no input, so can't be configured.