mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Add device rename to voice wizard (#25187)
Co-authored-by: Wendelin <w@pe8.at>
This commit is contained in:
parent
3058fcad46
commit
461d5eb687
@ -285,6 +285,7 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
|
|||||||
.assistConfiguration=${this
|
.assistConfiguration=${this
|
||||||
._assistConfiguration}
|
._assistConfiguration}
|
||||||
.assistEntityId=${assistSatelliteEntityId}
|
.assistEntityId=${assistSatelliteEntityId}
|
||||||
|
.deviceId=${this._params.deviceId}
|
||||||
></ha-voice-assistant-setup-step-success>`
|
></ha-voice-assistant-setup-step-success>`
|
||||||
: nothing}
|
: nothing}
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,6 +4,10 @@ import { css, html, LitElement, nothing } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { stopPropagation } from "../../common/dom/stop_propagation";
|
import { stopPropagation } from "../../common/dom/stop_propagation";
|
||||||
|
import {
|
||||||
|
computeDeviceName,
|
||||||
|
computeDeviceNameDisplay,
|
||||||
|
} from "../../common/entity/compute_device_name";
|
||||||
import "../../components/ha-list-item";
|
import "../../components/ha-list-item";
|
||||||
import "../../components/ha-select";
|
import "../../components/ha-select";
|
||||||
import "../../components/ha-tts-voice-picker";
|
import "../../components/ha-tts-voice-picker";
|
||||||
@ -18,6 +22,7 @@ import {
|
|||||||
setWakeWords,
|
setWakeWords,
|
||||||
} from "../../data/assist_satellite";
|
} from "../../data/assist_satellite";
|
||||||
import { fetchCloudStatus } from "../../data/cloud";
|
import { fetchCloudStatus } from "../../data/cloud";
|
||||||
|
import { updateDeviceRegistryEntry } from "../../data/device_registry";
|
||||||
import type { InputSelectEntity } from "../../data/input_select";
|
import type { InputSelectEntity } from "../../data/input_select";
|
||||||
import { setSelectOption } from "../../data/select";
|
import { setSelectOption } from "../../data/select";
|
||||||
import { showVoiceAssistantPipelineDetailDialog } from "../../panels/config/voice-assistants/show-dialog-voice-assistant-pipeline-detail";
|
import { showVoiceAssistantPipelineDetailDialog } from "../../panels/config/voice-assistants/show-dialog-voice-assistant-pipeline-detail";
|
||||||
@ -40,6 +45,10 @@ export class HaVoiceAssistantSetupStepSuccess extends LitElement {
|
|||||||
|
|
||||||
@state() private _ttsSettings?: any;
|
@state() private _ttsSettings?: any;
|
||||||
|
|
||||||
|
@state() private _error?: string;
|
||||||
|
|
||||||
|
private _deviceName?: string;
|
||||||
|
|
||||||
protected override willUpdate(changedProperties: PropertyValues): void {
|
protected override willUpdate(changedProperties: PropertyValues): void {
|
||||||
super.willUpdate(changedProperties);
|
super.willUpdate(changedProperties);
|
||||||
|
|
||||||
@ -68,6 +77,8 @@ export class HaVoiceAssistantSetupStepSuccess extends LitElement {
|
|||||||
] as InputSelectEntity)
|
] as InputSelectEntity)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
const device = this.hass.devices[this.deviceId];
|
||||||
|
|
||||||
return html`<div class="content">
|
return html`<div class="content">
|
||||||
<img
|
<img
|
||||||
src="/static/images/voice-assistant/heart.png"
|
src="/static/images/voice-assistant/heart.png"
|
||||||
@ -83,7 +94,20 @@ export class HaVoiceAssistantSetupStepSuccess extends LitElement {
|
|||||||
"ui.panel.config.voice_assistants.satellite_wizard.success.secondary"
|
"ui.panel.config.voice_assistants.satellite_wizard.success.secondary"
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
${this._error
|
||||||
|
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||||
|
: nothing}
|
||||||
<div class="rows">
|
<div class="rows">
|
||||||
|
<div class="row">
|
||||||
|
<ha-textfield
|
||||||
|
.label=${this.hass.localize(
|
||||||
|
"ui.panel.config.integrations.config_flow.device_name"
|
||||||
|
)}
|
||||||
|
.placeholder=${computeDeviceNameDisplay(device, this.hass)}
|
||||||
|
.value=${this._deviceName ?? computeDeviceName(device)}
|
||||||
|
@change=${this._deviceNameChanged}
|
||||||
|
></ha-textfield>
|
||||||
|
</div>
|
||||||
${this.assistConfiguration &&
|
${this.assistConfiguration &&
|
||||||
this.assistConfiguration.available_wake_words.length > 1
|
this.assistConfiguration.available_wake_words.length > 1
|
||||||
? html`<div class="row">
|
? html`<div class="row">
|
||||||
@ -156,7 +180,7 @@ export class HaVoiceAssistantSetupStepSuccess extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<ha-button @click=${this._close} unelevated
|
<ha-button @click=${this._done} unelevated
|
||||||
>${this.hass.localize(
|
>${this.hass.localize(
|
||||||
"ui.panel.config.voice_assistants.satellite_wizard.success.done"
|
"ui.panel.config.voice_assistants.satellite_wizard.success.done"
|
||||||
)}</ha-button
|
)}</ha-button
|
||||||
@ -188,6 +212,10 @@ export class HaVoiceAssistantSetupStepSuccess extends LitElement {
|
|||||||
return [pipeline, pipelines.preferred_pipeline];
|
return [pipeline, pipelines.preferred_pipeline];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _deviceNameChanged(ev) {
|
||||||
|
this._deviceName = ev.target.value;
|
||||||
|
}
|
||||||
|
|
||||||
private async _wakeWordPicked(ev) {
|
private async _wakeWordPicked(ev) {
|
||||||
const option = ev.target.value;
|
const option = ev.target.value;
|
||||||
await setWakeWords(this.hass, this.assistEntityId!, [option]);
|
await setWakeWords(this.hass, this.assistEntityId!, [option]);
|
||||||
@ -291,7 +319,20 @@ export class HaVoiceAssistantSetupStepSuccess extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _close() {
|
private async _done() {
|
||||||
|
if (this._deviceName) {
|
||||||
|
try {
|
||||||
|
updateDeviceRegistryEntry(this.hass, this.deviceId, {
|
||||||
|
name_by_user: this._deviceName,
|
||||||
|
});
|
||||||
|
} catch (error: any) {
|
||||||
|
this._error = this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.satellite_wizard.success.failed_rename",
|
||||||
|
{ error: error.message || error }
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
fireEvent(this, "closed");
|
fireEvent(this, "closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3553,7 +3553,8 @@
|
|||||||
"test_wakeword": "Test",
|
"test_wakeword": "Test",
|
||||||
"edit_pipeline": "Edit",
|
"edit_pipeline": "Edit",
|
||||||
"try_tts": "Try",
|
"try_tts": "Try",
|
||||||
"done": "Done"
|
"done": "Done",
|
||||||
|
"failed_rename": "Failed to rename the voice satellite: {error}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user