Improve code

This commit is contained in:
Paul Bottein 2025-07-03 19:17:53 +02:00
parent 9a12d563ec
commit efbfff9a4f
No known key found for this signature in database

View File

@ -307,7 +307,7 @@ export class MoreInfoDialog extends LitElement {
deviceName = this.hass.formatEntityName(stateObj, "device"); deviceName = this.hass.formatEntityName(stateObj, "device");
areaName = this.hass.formatEntityName(stateObj, "area"); areaName = this.hass.formatEntityName(stateObj, "area");
} else if (this._entry) { } else if (this._entry) {
const context = getEntityEntryContext( const { device, area } = getEntityEntryContext(
this._entry, this._entry,
this.hass.entities, this.hass.entities,
this.hass.devices, this.hass.devices,
@ -315,10 +315,8 @@ export class MoreInfoDialog extends LitElement {
this.hass.floors this.hass.floors
); );
entityName = computeEntityEntryName(this._entry, this.hass.devices); entityName = computeEntityEntryName(this._entry, this.hass.devices);
deviceName = context?.device deviceName = device ? computeDeviceName(device) : undefined;
? computeDeviceName(context.device) areaName = area ? computeAreaName(area) : undefined;
: undefined;
areaName = context?.area ? computeAreaName(context.area) : undefined;
} else { } else {
entityName = entityId; entityName = entityId;
} }