mirror of
https://github.com/home-assistant/frontend.git
synced 2025-06-18 08:06:35 +00:00
Add toggle switch for exposing of new entities to Assist (#23127)
This commit is contained in:
parent
8b6382448f
commit
14bebc76b0
@ -31,6 +31,10 @@ import {
|
|||||||
} from "../../../data/assist_pipeline";
|
} from "../../../data/assist_pipeline";
|
||||||
import type { CloudStatus } from "../../../data/cloud";
|
import type { CloudStatus } from "../../../data/cloud";
|
||||||
import type { ExposeEntitySettings } from "../../../data/expose";
|
import type { ExposeEntitySettings } from "../../../data/expose";
|
||||||
|
import {
|
||||||
|
getExposeNewEntities,
|
||||||
|
setExposeNewEntities,
|
||||||
|
} from "../../../data/expose";
|
||||||
import {
|
import {
|
||||||
showAlertDialog,
|
showAlertDialog,
|
||||||
showConfirmationDialog,
|
showConfirmationDialog,
|
||||||
@ -42,6 +46,7 @@ import { showVoiceAssistantPipelineDetailDialog } from "./show-dialog-voice-assi
|
|||||||
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";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
|
import type { HaSwitch } from "../../../components/ha-switch";
|
||||||
import { navigate } from "../../../common/navigate";
|
import { navigate } from "../../../common/navigate";
|
||||||
|
|
||||||
@customElement("assist-pref")
|
@customElement("assist-pref")
|
||||||
@ -61,6 +66,16 @@ export class AssistPref extends LitElement {
|
|||||||
|
|
||||||
@state() private _pipelineEntitiesCount = 0;
|
@state() private _pipelineEntitiesCount = 0;
|
||||||
|
|
||||||
|
@state() private _exposeNew?: boolean;
|
||||||
|
|
||||||
|
protected willUpdate() {
|
||||||
|
if (!this.hasUpdated) {
|
||||||
|
getExposeNewEntities(this.hass, "conversation").then((value) => {
|
||||||
|
this._exposeNew = value.expose_new;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected firstUpdated(changedProps: PropertyValues) {
|
protected firstUpdated(changedProps: PropertyValues) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
|
|
||||||
@ -193,6 +208,23 @@ export class AssistPref extends LitElement {
|
|||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="icon" .path=${mdiPlus}></ha-svg-icon>
|
<ha-svg-icon slot="icon" .path=${mdiPlus}></ha-svg-icon>
|
||||||
</ha-button>
|
</ha-button>
|
||||||
|
<ha-settings-row>
|
||||||
|
<span slot="heading">
|
||||||
|
${this.hass!.localize(
|
||||||
|
"ui.panel.config.voice_assistants.expose.expose_new_entities"
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span slot="description">
|
||||||
|
${this.hass!.localize(
|
||||||
|
"ui.panel.config.voice_assistants.expose.expose_new_entities_info"
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<ha-switch
|
||||||
|
.checked=${this._exposeNew}
|
||||||
|
.disabled=${this._exposeNew === undefined}
|
||||||
|
@change=${this._exposeNewToggleChanged}
|
||||||
|
></ha-switch>
|
||||||
|
</ha-settings-row>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<a
|
<a
|
||||||
href="/config/voice-assistants/expose?assistants=conversation&historyBack"
|
href="/config/voice-assistants/expose?assistants=conversation&historyBack"
|
||||||
@ -225,6 +257,18 @@ export class AssistPref extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _exposeNewToggleChanged(ev) {
|
||||||
|
const toggle = ev.target as HaSwitch;
|
||||||
|
if (this._exposeNew === undefined || this._exposeNew === toggle.checked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await setExposeNewEntities(this.hass, "conversation", toggle.checked);
|
||||||
|
} catch (err: any) {
|
||||||
|
toggle.checked = !toggle.checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _talkWithPipeline(ev) {
|
private _talkWithPipeline(ev) {
|
||||||
const id = ev.currentTarget.id as string;
|
const id = ev.currentTarget.id as string;
|
||||||
showVoiceCommandDialog(this, this.hass, { pipeline_id: id });
|
showVoiceCommandDialog(this, this.hass, { pipeline_id: id });
|
||||||
@ -332,6 +376,7 @@ export class AssistPref extends LitElement {
|
|||||||
--mdc-list-item-meta-size: auto;
|
--mdc-list-item-meta-size: auto;
|
||||||
--mdc-list-item-meta-display: flex;
|
--mdc-list-item-meta-display: flex;
|
||||||
--mdc-list-side-padding-right: 8px;
|
--mdc-list-side-padding-right: 8px;
|
||||||
|
--mdc-list-side-padding-left: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ha-list-item.danger {
|
ha-list-item.danger {
|
||||||
|
@ -2843,7 +2843,9 @@
|
|||||||
"header": "Expose entities",
|
"header": "Expose entities",
|
||||||
"expose_to": "to {assistants}",
|
"expose_to": "to {assistants}",
|
||||||
"expose_entities": "Expose {count} {count, plural,\n one {entity}\n other {entities}\n}"
|
"expose_entities": "Expose {count} {count, plural,\n one {entity}\n other {entities}\n}"
|
||||||
}
|
},
|
||||||
|
"expose_new_entities": "Expose new entities",
|
||||||
|
"expose_new_entities_info": "Should new entities be exposed? Exposes supported devices that are not classified as security devices."
|
||||||
},
|
},
|
||||||
"satellite_wizard": {
|
"satellite_wizard": {
|
||||||
"skip": "Skip",
|
"skip": "Skip",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user