Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/data/expose.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type { HomeAssistant } from "../types";
import type { EntityRegistryEntry } from "./entity/entity_registry";
import type { EntityRow } from "../panels/config/entities/ha-config-entities";

export const voiceAssistants = {
conversation: { domain: "assist_pipeline", name: "Assist" },
Expand Down Expand Up @@ -52,3 +54,10 @@ export const listExposedEntities = (hass: HomeAssistant) =>
hass.callWS<{ exposed_entities: Record<string, ExposeEntitySettings> }>({
type: "homeassistant/expose_entity/list",
});

export const getEntityVoiceAssistantsKeys = (
entity: EntityRegistryEntry | EntityRow
) =>
Object.keys(voiceAssistants).filter(
(vaKey) => entity?.options?.[vaKey]?.should_expose
);
33 changes: 32 additions & 1 deletion src/panels/config/automation/ha-automation-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ import type {
EntityRegistryEntry,
UpdateEntityRegistryEntryResult,
} from "../../../data/entity/entity_registry";
import { updateEntityRegistryEntry } from "../../../data/entity/entity_registry";
import {
entityRegistryByEntityId,
updateEntityRegistryEntry,
} from "../../../data/entity/entity_registry";
import type { LabelRegistryEntry } from "../../../data/label/label_registry";
import {
createLabelRegistryEntry,
Expand All @@ -115,6 +118,8 @@ import { showCategoryRegistryDetailDialog } from "../category/show-dialog-catego
import { configSections } from "../ha-panel-config";
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
import { showNewAutomationDialog } from "./show-dialog-new-automation";
import { getEntityVoiceAssistantsKeys } from "../../../data/expose";
import "../voice-assistants/expose/expose-assistant-icon";

type AutomationItem = AutomationEntity & {
name: string;
Expand Down Expand Up @@ -376,6 +381,32 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
></ha-icon-button>
`,
},
voice_assistants: {
title: localize(
"ui.panel.config.automation.picker.headers.voice_assistants"
),
type: "icon",
defaultHidden: true,
minWidth: "160px",
maxWidth: "160px",
template: (automation) => {
const entry = entityRegistryByEntityId(this._entityReg)[
automation.entity_id
];
const exposedToVoiceAssistantKeys =
getEntityVoiceAssistantsKeys(entry);
return html` ${exposedToVoiceAssistantKeys.length !== 0
? exposedToVoiceAssistantKeys.map(
(vaKey) =>
html` <voice-assistants-expose-assistant-icon
.assistant=${vaKey}
.hass=${this.hass}
>
</voice-assistants-expose-assistant-icon>`
)
: "—"}`;
},
},
};
return columns;
}
Expand Down
25 changes: 25 additions & 0 deletions src/panels/config/entities/ha-config-entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ import { isHelperDomain } from "../helpers/const";
import "../integrations/ha-integration-overflow-menu";
import { showAddIntegrationDialog } from "../integrations/show-add-integration-dialog";
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
import { getEntityVoiceAssistantsKeys } from "../../../data/expose";
import "../voice-assistants/expose/expose-assistant-icon";

export interface StateEntity extends Omit<
EntityRegistryEntry,
Expand Down Expand Up @@ -493,6 +495,29 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
template: (entry) =>
entry.label_entries.map((lbl) => lbl.name).join(" "),
},
voice_assistants: {
title: localize(
"ui.panel.config.entities.picker.headers.voice_assistants"
),
type: "icon",
defaultHidden: true,
minWidth: "160px",
maxWidth: "160px",
template: (entry) => {
const exposedToVoiceAssistantKeys =
getEntityVoiceAssistantsKeys(entry);
return html` ${exposedToVoiceAssistantKeys.length !== 0
? exposedToVoiceAssistantKeys.map(
(vaKey) =>
html` <voice-assistants-expose-assistant-icon
.assistant=${vaKey}
.hass=${this.hass}
>
</voice-assistants-expose-assistant-icon>`
)
: "—"}`;
},
},
})
);

Expand Down
28 changes: 28 additions & 0 deletions src/panels/config/helpers/ha-config-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ import "../integrations/ha-integration-overflow-menu";
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
import { isHelperDomain, type HelperDomain } from "./const";
import { showHelperDetailDialog } from "./show-dialog-helper-detail";
import { getEntityVoiceAssistantsKeys } from "../../../data/expose";
import "../voice-assistants/expose/expose-assistant-icon";

interface HelperItem {
id: string;
Expand Down Expand Up @@ -480,6 +482,32 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
</ha-icon-overflow-menu>
`,
},
voice_assistants: {
title: localize(
"ui.panel.config.helpers.picker.headers.voice_assistants"
),
type: "icon",
defaultHidden: true,
minWidth: "160px",
maxWidth: "160px",
template: (helper) => {
const entry = entityRegistryByEntityId(this._entityReg)[
helper.entity_id
];
const exposedToVoiceAssistantKeys =
getEntityVoiceAssistantsKeys(entry);
return html` ${exposedToVoiceAssistantKeys.length !== 0
? exposedToVoiceAssistantKeys.map(
(vaKey) =>
html` <voice-assistants-expose-assistant-icon
.assistant=${vaKey}
.hass=${this.hass}
>
</voice-assistants-expose-assistant-icon>`
)
: "—"}`;
},
},
})
);

Expand Down
33 changes: 32 additions & 1 deletion src/panels/config/scene/ha-scene-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ import type {
EntityRegistryEntry,
UpdateEntityRegistryEntryResult,
} from "../../../data/entity/entity_registry";
import { updateEntityRegistryEntry } from "../../../data/entity/entity_registry";
import {
entityRegistryByEntityId,
updateEntityRegistryEntry,
} from "../../../data/entity/entity_registry";
import { forwardHaptic } from "../../../data/haptics";
import type { LabelRegistryEntry } from "../../../data/label/label_registry";
import {
Expand Down Expand Up @@ -107,6 +110,8 @@ import { showAssignCategoryDialog } from "../category/show-dialog-assign-categor
import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail";
import { configSections } from "../ha-panel-config";
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
import { getEntityVoiceAssistantsKeys } from "../../../data/expose";
import "../voice-assistants/expose/expose-assistant-icon";

type SceneItem = SceneEntity & {
name: string;
Expand Down Expand Up @@ -410,6 +415,32 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
</ha-icon-overflow-menu>
`,
},
voice_assistants: {
title: localize(
"ui.panel.config.scene.picker.headers.voice_assistants"
),
type: "icon",
defaultHidden: true,
minWidth: "160px",
maxWidth: "160px",
template: (scene) => {
const entry = entityRegistryByEntityId(this._entityReg)[
scene.entity_id
];
const exposedToVoiceAssistantKeys =
getEntityVoiceAssistantsKeys(entry);
return html` ${exposedToVoiceAssistantKeys.length !== 0
? exposedToVoiceAssistantKeys.map(
(vaKey) =>
html` <voice-assistants-expose-assistant-icon
.assistant=${vaKey}
.hass=${this.hass}
>
</voice-assistants-expose-assistant-icon>`
)
: "—"}`;
},
},
};

return columns;
Expand Down
34 changes: 32 additions & 2 deletions src/panels/config/script/ha-script-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ import type {
EntityRegistryEntry,
UpdateEntityRegistryEntryResult,
} from "../../../data/entity/entity_registry";
import { updateEntityRegistryEntry } from "../../../data/entity/entity_registry";
import {
entityRegistryByEntityId,
updateEntityRegistryEntry,
} from "../../../data/entity/entity_registry";
import type { LabelRegistryEntry } from "../../../data/label/label_registry";
import {
createLabelRegistryEntry,
Expand Down Expand Up @@ -111,6 +114,8 @@ import { showAssignCategoryDialog } from "../category/show-dialog-assign-categor
import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail";
import { configSections } from "../ha-panel-config";
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
import { getEntityVoiceAssistantsKeys } from "../../../data/expose";
import "../voice-assistants/expose/expose-assistant-icon";

type ScriptItem = ScriptEntity & {
name: string;
Expand Down Expand Up @@ -398,8 +403,33 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
</ha-icon-overflow-menu>
`,
},
voice_assistants: {
title: localize(
"ui.panel.config.script.picker.headers.voice_assistants"
),
type: "icon",
defaultHidden: true,
minWidth: "160px",
maxWidth: "160px",
template: (script) => {
const entry = entityRegistryByEntityId(this._entityReg)[
script.entity_id
];
const exposedToVoiceAssistantKeys =
getEntityVoiceAssistantsKeys(entry);
return html` ${exposedToVoiceAssistantKeys.length !== 0
? exposedToVoiceAssistantKeys.map(
(vaKey) =>
html` <voice-assistants-expose-assistant-icon
.assistant=${vaKey}
.hass=${this.hass}
>
</voice-assistants-expose-assistant-icon>`
)
: "—"}`;
},
},
};

return columns;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class VoiceAssistantExposeAssistantIcon extends LitElement {

render() {
if (!this.assistant || !voiceAssistants[this.assistant]) return nothing;

return html`
<div class="container" id="container">
<img
Expand Down
15 changes: 10 additions & 5 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3342,7 +3342,8 @@
"type": "Type",
"editable": "Editable",
"category": "Category",
"area": "Area"
"area": "Area",
"voice_assistants": "Voice assistants"
},
"create_helper": "Create helper",
"no_helpers": "Looks like you don't have any helpers yet!",
Expand Down Expand Up @@ -3983,7 +3984,8 @@
"state": "State",
"category": "Category",
"area": "Area",
"icon": "Icon"
"icon": "Icon",
"voice_assistants": "Voice assistants"
},
"bulk_action": "Action",
"bulk_actions": {
Expand Down Expand Up @@ -5000,7 +5002,8 @@
"state": "State",
"category": "Category",
"area": "Area",
"icon": "Icon"
"icon": "Icon",
"voice_assistants": "Voice assistants"
},
"edit_category": "[%key:ui::panel::config::automation::picker::edit_category%]",
"assign_category": "[%key:ui::panel::config::automation::picker::assign_category%]",
Expand Down Expand Up @@ -5128,7 +5131,8 @@
"category": "Category",
"editable": "[%key:ui::panel::config::helpers::picker::headers::editable%]",
"area": "Area",
"icon": "Icon"
"icon": "Icon",
"voice_assistants": "Voice assistants"
},
"edit_category": "[%key:ui::panel::config::automation::picker::edit_category%]",
"assign_category": "[%key:ui::panel::config::automation::picker::assign_category%]",
Expand Down Expand Up @@ -5581,7 +5585,8 @@
"domain": "Domain",
"availability": "Availability",
"visibility": "Visibility",
"enabled": "Enabled"
"enabled": "Enabled",
"voice_assistants": "Voice assistants"
},
"selected": "{number} selected",
"enable_selected": {
Expand Down