Skip to content

Commit

Permalink
Migrate assist device count to satellite entity (#22486)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Oct 23, 2024
1 parent 7734922 commit 0b562a4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/panels/config/voice-assistants/assist-pref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ import "../../../components/ha-list-item";
import "../../../components/ha-svg-icon";
import "../../../components/ha-switch";
import {
AssistDevice,
AssistPipeline,
createAssistPipeline,
deleteAssistPipeline,
listAssistDevices,
listAssistPipelines,
setAssistPipelinePreferred,
updateAssistPipeline,
Expand All @@ -42,6 +40,7 @@ import { documentationUrl } from "../../../util/documentation-url";
import { showVoiceAssistantPipelineDetailDialog } from "./show-dialog-voice-assistant-pipeline-detail";
import { showVoiceCommandDialog } from "../../../dialogs/voice-command-dialog/show-ha-voice-command-dialog";
import { stopPropagation } from "../../../common/dom/stop_propagation";
import { computeDomain } from "../../../common/entity/compute_domain";

@customElement("assist-pref")
export class AssistPref extends LitElement {
Expand All @@ -58,7 +57,7 @@ export class AssistPref extends LitElement {

@state() private _preferred: string | null = null;

@state() private _devices: AssistDevice[] = [];
@state() private _pipelineEntitiesCount = 0;

protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
Expand All @@ -67,9 +66,9 @@ export class AssistPref extends LitElement {
this._pipelines = pipelines.pipelines;
this._preferred = pipelines.preferred_pipeline;
});
listAssistDevices(this.hass).then((devices) => {
this._devices = devices;
});
this._pipelineEntitiesCount = Object.values(this.hass.entities).filter(
(entity) => computeDomain(entity.entity_id) === "assist_satellite"
).length;
}

private _exposedEntitiesCount = memoizeOne(
Expand Down Expand Up @@ -205,13 +204,13 @@ export class AssistPref extends LitElement {
)}
</ha-button>
</a>
${this._devices?.length
${this._pipelineEntitiesCount > 0
? html`
<a href="/config/voice-assistants/assist/devices">
<ha-button>
${this.hass.localize(
"ui.panel.config.voice_assistants.assistants.pipeline.assist_devices",
{ number: this._devices.length }
{ number: this._pipelineEntitiesCount }
)}
</ha-button>
</a>
Expand Down

0 comments on commit 0b562a4

Please sign in to comment.