Skip to content

Commit 496b501

Browse files
committed
added Voice assistant column to data tables
1 parent 209abf4 commit 496b501

File tree

6 files changed

+202
-9
lines changed

6 files changed

+202
-9
lines changed

src/panels/config/automation/ha-automation-picker.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ import type {
9292
EntityRegistryEntry,
9393
UpdateEntityRegistryEntryResult,
9494
} from "../../../data/entity/entity_registry";
95-
import { updateEntityRegistryEntry } from "../../../data/entity/entity_registry";
95+
import {
96+
entityRegistryByEntityId,
97+
updateEntityRegistryEntry,
98+
} from "../../../data/entity/entity_registry";
9699
import type { LabelRegistryEntry } from "../../../data/label/label_registry";
97100
import {
98101
createLabelRegistryEntry,
@@ -115,6 +118,8 @@ import { showCategoryRegistryDetailDialog } from "../category/show-dialog-catego
115118
import { configSections } from "../ha-panel-config";
116119
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
117120
import { showNewAutomationDialog } from "./show-dialog-new-automation";
121+
import { voiceAssistants } from "../../../data/expose";
122+
import { brandsUrl } from "../../../util/brands-url";
118123

119124
type AutomationItem = AutomationEntity & {
120125
name: string;
@@ -376,6 +381,43 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
376381
></ha-icon-button>
377382
`,
378383
},
384+
voice_assistants: {
385+
title: localize(
386+
"ui.panel.config.automation.picker.headers.voice_assistants"
387+
),
388+
type: "icon",
389+
showNarrow: true,
390+
sortable: true,
391+
filterable: true,
392+
template: (automation) => {
393+
// const entry = this._entityReg.find(
394+
// (reg) => reg.entity_id === automation.entity_id
395+
// );
396+
const entry = entityRegistryByEntityId(this._entityReg)[
397+
automation.entity_id
398+
];
399+
return html` ${Object.keys(voiceAssistants).filter(
400+
(vaKey) => entry?.options?.[vaKey]?.should_expose
401+
).length !== 0
402+
? Object.keys(voiceAssistants)
403+
.filter((vaKey) => entry?.options?.[vaKey]?.should_expose)
404+
.map(
405+
(vaKey) =>
406+
html`<img
407+
alt=""
408+
src=${brandsUrl({
409+
domain: voiceAssistants[vaKey].domain,
410+
type: "icon",
411+
darkOptimized: this.hass.themes?.darkMode,
412+
})}
413+
crossorigin="anonymous"
414+
referrerpolicy="no-referrer"
415+
slot="prefix"
416+
/>`
417+
)
418+
: "—"}`;
419+
},
420+
},
379421
};
380422
return columns;
381423
}

src/panels/config/entities/ha-config-entities.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ import { isHelperDomain } from "../helpers/const";
115115
import "../integrations/ha-integration-overflow-menu";
116116
import { showAddIntegrationDialog } from "../integrations/show-add-integration-dialog";
117117
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
118+
import { voiceAssistants } from "../../../data/expose";
119+
import { brandsUrl } from "../../../util/brands-url";
118120

119121
export interface StateEntity extends Omit<
120122
EntityRegistryEntry,
@@ -493,6 +495,37 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
493495
template: (entry) =>
494496
entry.label_entries.map((lbl) => lbl.name).join(" "),
495497
},
498+
voice_assistants: {
499+
title: localize(
500+
"ui.panel.config.entities.picker.headers.voice_assistants"
501+
),
502+
type: "icon",
503+
showNarrow: true,
504+
sortable: true,
505+
filterable: true,
506+
template: (entry) =>
507+
html` ${Object.keys(voiceAssistants).filter(
508+
(vaKey) => entry?.options?.[vaKey]?.should_expose
509+
).length !== 0
510+
? Object.keys(voiceAssistants)
511+
.filter((vaKey) => entry?.options?.[vaKey]?.should_expose)
512+
.map(
513+
(vaKey) => html`
514+
<img
515+
alt=""
516+
src=${brandsUrl({
517+
domain: voiceAssistants[vaKey].domain,
518+
type: "icon",
519+
darkOptimized: this.hass.themes?.darkMode,
520+
})}
521+
crossorigin="anonymous"
522+
referrerpolicy="no-referrer"
523+
slot="prefix"
524+
/>
525+
`
526+
)
527+
: "—"}`,
528+
},
496529
})
497530
);
498531

src/panels/config/helpers/ha-config-helpers.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ import "../integrations/ha-integration-overflow-menu";
122122
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
123123
import { isHelperDomain, type HelperDomain } from "./const";
124124
import { showHelperDetailDialog } from "./show-dialog-helper-detail";
125+
import { voiceAssistants } from "../../../data/expose";
126+
import { brandsUrl } from "../../../util/brands-url";
125127

126128
interface HelperItem {
127129
id: string;
@@ -480,6 +482,40 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
480482
</ha-icon-overflow-menu>
481483
`,
482484
},
485+
voice_assistants: {
486+
title: localize(
487+
"ui.panel.config.helpers.picker.headers.voice_assistants"
488+
),
489+
type: "icon",
490+
showNarrow: true,
491+
sortable: true,
492+
filterable: true,
493+
template: (helper) => {
494+
const entry = entityRegistryByEntityId(this._entityReg)[
495+
helper.entity_id
496+
];
497+
return html` ${Object.keys(voiceAssistants).filter(
498+
(vaKey) => entry?.options?.[vaKey]?.should_expose
499+
).length !== 0
500+
? Object.keys(voiceAssistants)
501+
.filter((vaKey) => entry?.options?.[vaKey]?.should_expose)
502+
.map(
503+
(vaKey) =>
504+
html`<img
505+
alt=""
506+
src=${brandsUrl({
507+
domain: voiceAssistants[vaKey].domain,
508+
type: "icon",
509+
darkOptimized: this.hass.themes?.darkMode,
510+
})}
511+
crossorigin="anonymous"
512+
referrerpolicy="no-referrer"
513+
slot="prefix"
514+
/>`
515+
)
516+
: "—"}`;
517+
},
518+
},
483519
})
484520
);
485521

src/panels/config/scene/ha-scene-dashboard.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ import type {
7777
EntityRegistryEntry,
7878
UpdateEntityRegistryEntryResult,
7979
} from "../../../data/entity/entity_registry";
80-
import { updateEntityRegistryEntry } from "../../../data/entity/entity_registry";
80+
import {
81+
entityRegistryByEntityId,
82+
updateEntityRegistryEntry,
83+
} from "../../../data/entity/entity_registry";
8184
import { forwardHaptic } from "../../../data/haptics";
8285
import type { LabelRegistryEntry } from "../../../data/label/label_registry";
8386
import {
@@ -107,6 +110,8 @@ import { showAssignCategoryDialog } from "../category/show-dialog-assign-categor
107110
import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail";
108111
import { configSections } from "../ha-panel-config";
109112
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
113+
import { voiceAssistants } from "../../../data/expose";
114+
import { brandsUrl } from "../../../util/brands-url";
110115

111116
type SceneItem = SceneEntity & {
112117
name: string;
@@ -410,6 +415,40 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
410415
</ha-icon-overflow-menu>
411416
`,
412417
},
418+
voice_assistants: {
419+
title: localize(
420+
"ui.panel.config.scene.picker.headers.voice_assistants"
421+
),
422+
type: "icon",
423+
showNarrow: true,
424+
sortable: true,
425+
filterable: true,
426+
template: (scene) => {
427+
const entry = entityRegistryByEntityId(this._entityReg)[
428+
scene.entity_id
429+
];
430+
return html` ${Object.keys(voiceAssistants).filter(
431+
(vaKey) => entry?.options?.[vaKey]?.should_expose
432+
).length !== 0
433+
? Object.keys(voiceAssistants)
434+
.filter((vaKey) => entry?.options?.[vaKey]?.should_expose)
435+
.map(
436+
(vaKey) =>
437+
html`<img
438+
alt=""
439+
src=${brandsUrl({
440+
domain: voiceAssistants[vaKey].domain,
441+
type: "icon",
442+
darkOptimized: this.hass.themes?.darkMode,
443+
})}
444+
crossorigin="anonymous"
445+
referrerpolicy="no-referrer"
446+
slot="prefix"
447+
/>`
448+
)
449+
: "—"}`;
450+
},
451+
},
413452
};
414453

415454
return columns;

src/panels/config/script/ha-script-picker.ts

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ import type {
7878
EntityRegistryEntry,
7979
UpdateEntityRegistryEntryResult,
8080
} from "../../../data/entity/entity_registry";
81-
import { updateEntityRegistryEntry } from "../../../data/entity/entity_registry";
81+
import {
82+
entityRegistryByEntityId,
83+
updateEntityRegistryEntry,
84+
} from "../../../data/entity/entity_registry";
8285
import type { LabelRegistryEntry } from "../../../data/label/label_registry";
8386
import {
8487
createLabelRegistryEntry,
@@ -111,6 +114,8 @@ import { showAssignCategoryDialog } from "../category/show-dialog-assign-categor
111114
import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail";
112115
import { configSections } from "../ha-panel-config";
113116
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
117+
import { voiceAssistants } from "../../../data/expose";
118+
import { brandsUrl } from "../../../util/brands-url";
114119

115120
type ScriptItem = ScriptEntity & {
116121
name: string;
@@ -398,8 +403,41 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
398403
</ha-icon-overflow-menu>
399404
`,
400405
},
406+
voice_assistants: {
407+
title: localize(
408+
"ui.panel.config.script.picker.headers.voice_assistants"
409+
),
410+
type: "icon",
411+
showNarrow: true,
412+
sortable: true,
413+
filterable: true,
414+
template: (script) => {
415+
const entry = entityRegistryByEntityId(this._entityReg)[
416+
script.entity_id
417+
];
418+
return html` ${Object.keys(voiceAssistants).filter(
419+
(vaKey) => entry?.options?.[vaKey]?.should_expose
420+
).length !== 0
421+
? Object.keys(voiceAssistants)
422+
.filter((vaKey) => entry?.options?.[vaKey]?.should_expose)
423+
.map(
424+
(vaKey) =>
425+
html`<img
426+
alt=""
427+
src=${brandsUrl({
428+
domain: voiceAssistants[vaKey].domain,
429+
type: "icon",
430+
darkOptimized: this.hass.themes?.darkMode,
431+
})}
432+
crossorigin="anonymous"
433+
referrerpolicy="no-referrer"
434+
slot="prefix"
435+
/>`
436+
)
437+
: "—"}`;
438+
},
439+
},
401440
};
402-
403441
return columns;
404442
}
405443
);

src/translations/en.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3342,7 +3342,8 @@
33423342
"type": "Type",
33433343
"editable": "Editable",
33443344
"category": "Category",
3345-
"area": "Area"
3345+
"area": "Area",
3346+
"voice_assistants": "Voice assistants"
33463347
},
33473348
"create_helper": "Create helper",
33483349
"no_helpers": "Looks like you don't have any helpers yet!",
@@ -3983,7 +3984,8 @@
39833984
"state": "State",
39843985
"category": "Category",
39853986
"area": "Area",
3986-
"icon": "Icon"
3987+
"icon": "Icon",
3988+
"voice_assistants": "Voice assistants"
39873989
},
39883990
"bulk_action": "Action",
39893991
"bulk_actions": {
@@ -4999,7 +5001,8 @@
49995001
"state": "State",
50005002
"category": "Category",
50015003
"area": "Area",
5002-
"icon": "Icon"
5004+
"icon": "Icon",
5005+
"voice_assistants": "Voice assistants"
50035006
},
50045007
"edit_category": "[%key:ui::panel::config::automation::picker::edit_category%]",
50055008
"assign_category": "[%key:ui::panel::config::automation::picker::assign_category%]",
@@ -5127,7 +5130,8 @@
51275130
"category": "Category",
51285131
"editable": "[%key:ui::panel::config::helpers::picker::headers::editable%]",
51295132
"area": "Area",
5130-
"icon": "Icon"
5133+
"icon": "Icon",
5134+
"voice_assistants": "Voice assistants"
51315135
},
51325136
"edit_category": "[%key:ui::panel::config::automation::picker::edit_category%]",
51335137
"assign_category": "[%key:ui::panel::config::automation::picker::assign_category%]",
@@ -5580,7 +5584,8 @@
55805584
"domain": "Domain",
55815585
"availability": "Availability",
55825586
"visibility": "Visibility",
5583-
"enabled": "Enabled"
5587+
"enabled": "Enabled",
5588+
"voice_assistants": "Voice assistants"
55845589
},
55855590
"selected": "{number} selected",
55865591
"enable_selected": {

0 commit comments

Comments
 (0)