Skip to content

Commit

Permalink
fix: Set Home Assistant entity categories config and diagnostic a…
Browse files Browse the repository at this point in the history
…ccording to expose categories (#20663)

* Add exposes starting with 'config' or 'diagnostic' to respective Home Assistant categories

* alt proposal: default category based on new Expose property

* Use single category 'system' instead of 'config' and 'diagnostic'

* Revert "Use single category 'system' instead of 'config' and 'diagnostic'"

This reverts commit 416dd9c.

* lint
  • Loading branch information
slugzero authored Jan 9, 2024
1 parent ce7d022 commit 363792a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/extension/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 363792a

Please sign in to comment.