mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +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}
|
||||
.assistEntityId=${assistSatelliteEntityId}
|
||||
.deviceId=${this._params.deviceId}
|
||||
></ha-voice-assistant-setup-step-success>`
|
||||
: nothing}
|
||||
</div>
|
||||
|
@ -4,6 +4,10 @@ import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { stopPropagation } from "../../common/dom/stop_propagation";
|
||||
import {
|
||||
computeDeviceName,
|
||||
computeDeviceNameDisplay,
|
||||
} from "../../common/entity/compute_device_name";
|
||||
import "../../components/ha-list-item";
|
||||
import "../../components/ha-select";
|
||||
import "../../components/ha-tts-voice-picker";
|
||||
@ -18,6 +22,7 @@ import {
|
||||
setWakeWords,
|
||||
} from "../../data/assist_satellite";
|
||||
import { fetchCloudStatus } from "../../data/cloud";
|
||||
import { updateDeviceRegistryEntry } from "../../data/device_registry";
|
||||
import type { InputSelectEntity } from "../../data/input_select";
|
||||
import { setSelectOption } from "../../data/select";
|
||||
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 _error?: string;
|
||||
|
||||
private _deviceName?: string;
|
||||
|
||||
protected override willUpdate(changedProperties: PropertyValues): void {
|
||||
super.willUpdate(changedProperties);
|
||||
|
||||
@ -68,6 +77,8 @@ export class HaVoiceAssistantSetupStepSuccess extends LitElement {
|
||||
] as InputSelectEntity)
|
||||
: undefined;
|
||||
|
||||
const device = this.hass.devices[this.deviceId];
|
||||
|
||||
return html`<div class="content">
|
||||
<img
|
||||
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"
|
||||
)}
|
||||
</p>
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
: nothing}
|
||||
<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.available_wake_words.length > 1
|
||||
? html`<div class="row">
|
||||
@ -156,7 +180,7 @@ export class HaVoiceAssistantSetupStepSuccess extends LitElement {
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<ha-button @click=${this._close} unelevated
|
||||
<ha-button @click=${this._done} unelevated
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.satellite_wizard.success.done"
|
||||
)}</ha-button
|
||||
@ -188,6 +212,10 @@ export class HaVoiceAssistantSetupStepSuccess extends LitElement {
|
||||
return [pipeline, pipelines.preferred_pipeline];
|
||||
}
|
||||
|
||||
private _deviceNameChanged(ev) {
|
||||
this._deviceName = ev.target.value;
|
||||
}
|
||||
|
||||
private async _wakeWordPicked(ev) {
|
||||
const option = ev.target.value;
|
||||
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");
|
||||
}
|
||||
|
||||
|
@ -3553,7 +3553,8 @@
|
||||
"test_wakeword": "Test",
|
||||
"edit_pipeline": "Edit",
|
||||
"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