Compare commits

..
Author SHA1 Message Date
Franck Nijhof 1ecbf27e30 Add a serial number column to the devices table 2026-11-24 17:46:53 +00:00
4 changed files with 36 additions and 57 deletions

No files matched your search

+1 -3
View File
@@ -775,15 +775,13 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
ha-list-item-button {
flex-shrink: 0;
margin: 0 0 var(--ha-space-1);
margin-inline-start: var(--ha-space-1);
margin: 0 var(--ha-space-1) var(--ha-space-1);
border-radius: var(--ha-border-radius-sm);
--ha-row-item-min-height: var(--ha-space-10);
--ha-row-item-padding-block: 0;
--ha-row-item-padding-inline: var(--ha-space-3);
width: var(--ha-space-12);
position: relative;
overflow: clip;
transition: width var(--ha-animation-duration-normal) ease;
}
ha-list-item-button::part(headline) {
@@ -514,6 +514,7 @@ export class HaConfigDeviceDashboard extends LitElement {
? computeDeviceNameDisplay(familyParentDevice, this.hass.localize)
: undefined,
firmware_version: device.sw_version || undefined,
serial_number: device.serial_number || undefined,
battery_entity: [
this._batteryEntity(device.id, deviceEntityLookup),
this._batteryChargingEntity(device.id, deviceEntityLookup),
@@ -656,6 +657,13 @@ export class HaConfigDeviceDashboard extends LitElement {
defaultHidden: true,
minWidth: "120px",
},
serial_number: {
title: localize("ui.panel.config.devices.data_table.serial_number"),
sortable: true,
filterable: true,
defaultHidden: true,
minWidth: "120px",
},
battery_entity: {
title: localize("ui.panel.config.devices.data_table.battery"),
showNarrow: true,
+26 -54
View File
@@ -328,57 +328,29 @@ export class HuiAreaCard extends LitElement implements LovelaceCard {
}
);
private _domainEntityIds = (
entities: HomeAssistant["entities"],
areaId: string,
domains: string[],
excludeEntities?: string[]
): string[] => {
const filter = generateEntityFilter(
this.hass.states,
this.hass.entities,
this.hass.devices,
this.hass.areas,
this.hass.floors,
{
area: areaId,
entity_category: "none",
domain: domains,
}
);
return Object.keys(entities).filter(
(id) => filter(id) && !excludeEntities?.includes(id)
);
};
/**
* Entities in the area that can supply a sensor value through an attribute
* (see SENSOR_ATTRIBUTE_SOURCES), grouped by the sensor class they supply.
*
* @returns Map of sensor class to entity IDs, e.g.
* { "temperature" => ["climate.living_room"],
* "humidity" => ["climate.living_room", "humidifier.bedroom"] }
*/
private _attributeSourceEntityIds = memoizeOne(
private _domainEntityIds = memoizeOne(
(
entities: HomeAssistant["entities"],
areaId: string,
sensorClasses: string[],
domains: string[],
excludeEntities?: string[]
): Map<string, string[]> =>
new Map(
sensorClasses
.filter((sensorClass) => sensorClass in SENSOR_ATTRIBUTE_SOURCES)
.map((sensorClass) => [
sensorClass,
this._domainEntityIds(
entities,
areaId,
SENSOR_ATTRIBUTE_SOURCES[sensorClass].map((s) => s.domain),
excludeEntities
),
])
)
): string[] => {
const filter = generateEntityFilter(
this.hass.states,
this.hass.entities,
this.hass.devices,
this.hass.areas,
this.hass.floors,
{
area: areaId,
entity_category: "none",
domain: domains,
}
);
return Object.keys(entities).filter(
(id) => filter(id) && !excludeEntities?.includes(id)
);
}
);
private _computeActiveAlertStates(): HassEntity[] {
@@ -522,13 +494,13 @@ export class HuiAreaCard extends LitElement implements LovelaceCard {
// Collect values from additional attribute sources
const attrSources = SENSOR_ATTRIBUTE_SOURCES[sensorClass];
if (attrSources) {
const attrEntityIds =
this._attributeSourceEntityIds(
this.hass.entities,
area.area_id,
sensorClasses,
excludeEntities
).get(sensorClass) ?? [];
const domains = [...new Set(attrSources.map((s) => s.domain))];
const attrEntityIds = this._domainEntityIds(
this.hass.entities,
area.area_id,
domains,
excludeEntities
);
for (const entityId of attrEntityIds) {
const stateObj = this.hass.states[entityId];
+1
View File
@@ -7794,6 +7794,7 @@
"part_of_device": "Part of {name}",
"connected_via": "[%key:ui::panel::config::integrations::config_entry::via%]",
"firmware_version": "Firmware",
"serial_number": "[%key:ui::panel::config::serial::fields::serial_number%]",
"battery": "Battery",
"disabled_by": "Disabled",
"no_devices": "No devices",