From ce90d83c92ed807ab6e25878154af0c11c3ce640 Mon Sep 17 00:00:00 2001 From: Alex Gustafsson Date: Wed, 25 Mar 2026 08:03:45 +0100 Subject: [PATCH] ZHA group settings UI improvements, localization (#30251) * Add device area column to ZHA data table Add a device area column to the ZHA data table, which most notably adds the column to the "create [ZigBee] group" view". The column is only show on wider screens to allow for ordering, whilst narrower screens will show the area as a subtitle to the device's name. * Localize the ZHA group data table * fixup! Add device area column to ZHA data table * fixup! Localize the ZHA group data table --- .../zha/zha-device-endpoint-data-table.ts | 46 +++++++++++++------ src/translations/en.json | 5 +- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/panels/config/integrations/integration-panels/zha/zha-device-endpoint-data-table.ts b/src/panels/config/integrations/integration-panels/zha/zha-device-endpoint-data-table.ts index 1831a66e1e..2a2d419248 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-device-endpoint-data-table.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-device-endpoint-data-table.ts @@ -1,5 +1,5 @@ import type { CSSResultGroup, TemplateResult } from "lit"; -import { css, html, LitElement } from "lit"; +import { css, html, LitElement, nothing } from "lit"; import { customElement, property, query } from "lit/decorators"; import memoizeOne from "memoize-one"; import "../../../../../components/data-table/ha-data-table"; @@ -13,10 +13,14 @@ import type { ZHAEntityReference, } from "../../../../../data/zha"; import type { HomeAssistant } from "../../../../../types"; +import { getAreaTableColumn } from "../../../common/data-table-columns"; +import type { LocalizeFunc } from "../../../../../common/translations/localize"; +import type { AreaRegistryEntry } from "../../../../../data/area/area_registry"; export interface DeviceEndpointRowData extends DataTableRowData { id: string; name: string; + area: string | undefined; model: string; manufacturer: string; endpoint_id: number; @@ -37,13 +41,18 @@ export class ZHADeviceEndpointDataTable extends LitElement { @query("ha-data-table", true) private _dataTable!: HaDataTable; private _deviceEndpoints = memoizeOne( - (deviceEndpoints: ZHADeviceEndpoint[]) => { + ( + deviceEndpoints: ZHADeviceEndpoint[], + areas: Record + ) => { const outputDevices: DeviceEndpointRowData[] = []; - deviceEndpoints.forEach((deviceEndpoint) => { outputDevices.push({ name: deviceEndpoint.device.user_given_name || deviceEndpoint.device.name, + area: deviceEndpoint.device.area_id + ? areas[deviceEndpoint.device.area_id].name + : undefined, model: deviceEndpoint.device.model, manufacturer: deviceEndpoint.device.manufacturer, id: deviceEndpoint.device.ieee + "_" + deviceEndpoint.endpoint_id, @@ -59,11 +68,11 @@ export class ZHADeviceEndpointDataTable extends LitElement { ); private _columns = memoizeOne( - (narrow: boolean): DataTableColumnContainer => + (localize: LocalizeFunc, narrow: boolean): DataTableColumnContainer => narrow ? { name: { - title: "Devices", + title: localize("ui.panel.config.zha.groups.members"), sortable: true, filterable: true, direction: "asc", @@ -71,18 +80,26 @@ export class ZHADeviceEndpointDataTable extends LitElement { template: (device) => html` ${device.name} + ${device.area + ? html`
+ + ${device.area} + ` + : nothing}
`, }, endpoint_id: { - title: "Endpoint", + title: localize("ui.panel.config.zha.groups.endpoint"), sortable: true, filterable: true, }, } : { name: { - title: "Name", + title: localize("ui.panel.config.zha.groups.members"), sortable: true, filterable: true, direction: "asc", @@ -93,13 +110,14 @@ export class ZHADeviceEndpointDataTable extends LitElement { `, }, + area: getAreaTableColumn(localize), endpoint_id: { - title: "Endpoint", + title: localize("ui.panel.config.zha.groups.endpoint"), sortable: true, filterable: true, }, entities: { - title: "Associated Entities", + title: localize("ui.panel.config.zha.groups.associated_entities"), sortable: false, filterable: false, flex: 2, @@ -116,7 +134,7 @@ export class ZHADeviceEndpointDataTable extends LitElement { ${entity.name || entity.original_name} ` )} -
And ${device.entities.length - 2} more...
` +
+${device.entities.length - 2}
` : device.entities.map( (entity) => html`
` ) - : "This endpoint has no associated entities"} + : localize( + "ui.panel.config.zha.groups.no_associated_entities" + )} `, }, } @@ -139,8 +159,8 @@ export class ZHADeviceEndpointDataTable extends LitElement { return html`