Migrate assist device count to satellite entity (#22486)

This commit is contained in:
Paulus Schoutsen 2024-10-23 03:23:27 -04:00 committed by GitHub
parent 7734922059
commit 0b562a4b16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,11 +21,9 @@ import "../../../components/ha-list-item";
import "../../../components/ha-svg-icon"; import "../../../components/ha-svg-icon";
import "../../../components/ha-switch"; import "../../../components/ha-switch";
import { import {
AssistDevice,
AssistPipeline, AssistPipeline,
createAssistPipeline, createAssistPipeline,
deleteAssistPipeline, deleteAssistPipeline,
listAssistDevices,
listAssistPipelines, listAssistPipelines,
setAssistPipelinePreferred, setAssistPipelinePreferred,
updateAssistPipeline, updateAssistPipeline,
@ -42,6 +40,7 @@ import { documentationUrl } from "../../../util/documentation-url";
import { showVoiceAssistantPipelineDetailDialog } from "./show-dialog-voice-assistant-pipeline-detail"; import { showVoiceAssistantPipelineDetailDialog } from "./show-dialog-voice-assistant-pipeline-detail";
import { showVoiceCommandDialog } from "../../../dialogs/voice-command-dialog/show-ha-voice-command-dialog"; import { showVoiceCommandDialog } from "../../../dialogs/voice-command-dialog/show-ha-voice-command-dialog";
import { stopPropagation } from "../../../common/dom/stop_propagation"; import { stopPropagation } from "../../../common/dom/stop_propagation";
import { computeDomain } from "../../../common/entity/compute_domain";
@customElement("assist-pref") @customElement("assist-pref")
export class AssistPref extends LitElement { export class AssistPref extends LitElement {
@ -58,7 +57,7 @@ export class AssistPref extends LitElement {
@state() private _preferred: string | null = null; @state() private _preferred: string | null = null;
@state() private _devices: AssistDevice[] = []; @state() private _pipelineEntitiesCount = 0;
protected firstUpdated(changedProps: PropertyValues) { protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps); super.firstUpdated(changedProps);
@ -67,9 +66,9 @@ export class AssistPref extends LitElement {
this._pipelines = pipelines.pipelines; this._pipelines = pipelines.pipelines;
this._preferred = pipelines.preferred_pipeline; this._preferred = pipelines.preferred_pipeline;
}); });
listAssistDevices(this.hass).then((devices) => { this._pipelineEntitiesCount = Object.values(this.hass.entities).filter(
this._devices = devices; (entity) => computeDomain(entity.entity_id) === "assist_satellite"
}); ).length;
} }
private _exposedEntitiesCount = memoizeOne( private _exposedEntitiesCount = memoizeOne(
@ -205,13 +204,13 @@ export class AssistPref extends LitElement {
)} )}
</ha-button> </ha-button>
</a> </a>
${this._devices?.length ${this._pipelineEntitiesCount > 0
? html` ? html`
<a href="/config/voice-assistants/assist/devices"> <a href="/config/voice-assistants/assist/devices">
<ha-button> <ha-button>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.voice_assistants.assistants.pipeline.assist_devices", "ui.panel.config.voice_assistants.assistants.pipeline.assist_devices",
{ number: this._devices.length } { number: this._pipelineEntitiesCount }
)} )}
</ha-button> </ha-button>
</a> </a>