mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 20:36:35 +00:00
Use entity name in device info page (#13165)
* Use entity name in device info page * Adjust to new format * Use latest API * Fix types * Fix CI? Co-authored-by: Zack <zackbarett@hey.com>
This commit is contained in:
parent
437723c6a6
commit
729e2f5248
@ -1,5 +1,4 @@
|
|||||||
// Compat needs to be first import
|
// Compat needs to be first import
|
||||||
import "../../src/resources/compatibility";
|
|
||||||
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
||||||
import { navigate } from "../../src/common/navigate";
|
import { navigate } from "../../src/common/navigate";
|
||||||
import {
|
import {
|
||||||
@ -7,9 +6,14 @@ import {
|
|||||||
provideHass,
|
provideHass,
|
||||||
} from "../../src/fake_data/provide_hass";
|
} from "../../src/fake_data/provide_hass";
|
||||||
import { HomeAssistantAppEl } from "../../src/layouts/home-assistant";
|
import { HomeAssistantAppEl } from "../../src/layouts/home-assistant";
|
||||||
|
import "../../src/resources/compatibility";
|
||||||
import { HomeAssistant } from "../../src/types";
|
import { HomeAssistant } from "../../src/types";
|
||||||
import { selectedDemoConfig } from "./configs/demo-configs";
|
import { selectedDemoConfig } from "./configs/demo-configs";
|
||||||
import { mockAuth } from "./stubs/auth";
|
import { mockAuth } from "./stubs/auth";
|
||||||
|
import { mockConfigEntries } from "./stubs/config_entries";
|
||||||
|
import { mockEnergy } from "./stubs/energy";
|
||||||
|
import { energyEntities } from "./stubs/entities";
|
||||||
|
import { mockEntityRegistry } from "./stubs/entity_registry";
|
||||||
import { mockEvents } from "./stubs/events";
|
import { mockEvents } from "./stubs/events";
|
||||||
import { mockFrontend } from "./stubs/frontend";
|
import { mockFrontend } from "./stubs/frontend";
|
||||||
import { mockHistory } from "./stubs/history";
|
import { mockHistory } from "./stubs/history";
|
||||||
@ -20,10 +24,6 @@ import { mockShoppingList } from "./stubs/shopping_list";
|
|||||||
import { mockSystemLog } from "./stubs/system_log";
|
import { mockSystemLog } from "./stubs/system_log";
|
||||||
import { mockTemplate } from "./stubs/template";
|
import { mockTemplate } from "./stubs/template";
|
||||||
import { mockTranslations } from "./stubs/translations";
|
import { mockTranslations } from "./stubs/translations";
|
||||||
import { mockEnergy } from "./stubs/energy";
|
|
||||||
import { energyEntities } from "./stubs/entities";
|
|
||||||
import { mockConfigEntries } from "./stubs/config_entries";
|
|
||||||
import { mockEntityRegistry } from "./stubs/entity_registry";
|
|
||||||
|
|
||||||
class HaDemo extends HomeAssistantAppEl {
|
class HaDemo extends HomeAssistantAppEl {
|
||||||
protected async _initializeHass() {
|
protected async _initializeHass() {
|
||||||
@ -66,6 +66,7 @@ class HaDemo extends HomeAssistantAppEl {
|
|||||||
platform: "co2signal",
|
platform: "co2signal",
|
||||||
hidden_by: null,
|
hidden_by: null,
|
||||||
entity_category: null,
|
entity_category: null,
|
||||||
|
has_entity_name: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
config_entry_id: "co2signal",
|
config_entry_id: "co2signal",
|
||||||
@ -78,6 +79,7 @@ class HaDemo extends HomeAssistantAppEl {
|
|||||||
platform: "co2signal",
|
platform: "co2signal",
|
||||||
hidden_by: null,
|
hidden_by: null,
|
||||||
entity_category: null,
|
entity_category: null,
|
||||||
|
has_entity_name: false,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -194,6 +194,7 @@ const createEntityRegistryEntries = (
|
|||||||
name: null,
|
name: null,
|
||||||
icon: null,
|
icon: null,
|
||||||
platform: "updater",
|
platform: "updater",
|
||||||
|
has_entity_name: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -16,12 +16,13 @@ export interface EntityRegistryEntry {
|
|||||||
disabled_by: string | null;
|
disabled_by: string | null;
|
||||||
hidden_by: string | null;
|
hidden_by: string | null;
|
||||||
entity_category: "config" | "diagnostic" | null;
|
entity_category: "config" | "diagnostic" | null;
|
||||||
|
has_entity_name: boolean;
|
||||||
|
original_name?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExtEntityRegistryEntry extends EntityRegistryEntry {
|
export interface ExtEntityRegistryEntry extends EntityRegistryEntry {
|
||||||
unique_id: string;
|
unique_id: string;
|
||||||
capabilities: Record<string, unknown>;
|
capabilities: Record<string, unknown>;
|
||||||
original_name?: string;
|
|
||||||
original_icon?: string;
|
original_icon?: string;
|
||||||
device_class?: string;
|
device_class?: string;
|
||||||
original_device_class?: string;
|
original_device_class?: string;
|
||||||
|
@ -163,17 +163,27 @@ export class HaDeviceEntitiesCard extends LitElement {
|
|||||||
if (this.hass) {
|
if (this.hass) {
|
||||||
element.hass = this.hass;
|
element.hass = this.hass;
|
||||||
const stateObj = this.hass.states[entry.entity_id];
|
const stateObj = this.hass.states[entry.entity_id];
|
||||||
const name = stripPrefixFromEntityName(
|
|
||||||
computeStateName(stateObj),
|
let name = entry.name
|
||||||
this.deviceName.toLowerCase()
|
? entry.name
|
||||||
);
|
: entry.has_entity_name
|
||||||
if (entry.hidden_by) {
|
? entry.original_name || this.deviceName
|
||||||
config.name = `${
|
: stripPrefixFromEntityName(
|
||||||
name || computeStateName(stateObj)
|
computeStateName(stateObj),
|
||||||
} (${this.hass.localize("ui.panel.config.devices.entities.hidden")})`;
|
this.deviceName.toLowerCase()
|
||||||
} else if (name) {
|
);
|
||||||
config.name = name;
|
|
||||||
|
if (!name) {
|
||||||
|
name = computeStateName(stateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entry.hidden_by) {
|
||||||
|
name += ` (${this.hass.localize(
|
||||||
|
"ui.panel.config.devices.entities.hidden"
|
||||||
|
)})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
config.name = name;
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
element.entry = entry;
|
element.entry = entry;
|
||||||
|
@ -736,6 +736,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
readonly: true,
|
readonly: true,
|
||||||
selectable: false,
|
selectable: false,
|
||||||
entity_category: null,
|
entity_category: null,
|
||||||
|
has_entity_name: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user