mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 23:36:36 +00:00
Use entity registry icon directly (#19466)
This commit is contained in:
parent
619675318c
commit
809df848ef
@ -17,10 +17,12 @@ export class HaStateIcon extends LitElement {
|
|||||||
@property() public icon?: string;
|
@property() public icon?: string;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (this.icon || this.stateObj?.attributes.icon) {
|
const overrideIcon =
|
||||||
return html`<ha-icon
|
this.icon ||
|
||||||
.icon=${this.icon || this.stateObj?.attributes.icon}
|
(this.stateObj && this.hass?.entities[this.stateObj.entity_id]?.icon) ||
|
||||||
></ha-icon>`;
|
this.stateObj?.attributes.icon;
|
||||||
|
if (overrideIcon) {
|
||||||
|
return html`<ha-icon .icon=${overrideIcon}></ha-icon>`;
|
||||||
}
|
}
|
||||||
if (!this.stateObj) {
|
if (!this.stateObj) {
|
||||||
return nothing;
|
return nothing;
|
||||||
|
@ -15,6 +15,7 @@ type entityCategory = "config" | "diagnostic";
|
|||||||
export interface EntityRegistryDisplayEntry {
|
export interface EntityRegistryDisplayEntry {
|
||||||
entity_id: string;
|
entity_id: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
icon?: string;
|
||||||
device_id?: string;
|
device_id?: string;
|
||||||
area_id?: string;
|
area_id?: string;
|
||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
@ -31,6 +32,7 @@ export interface EntityRegistryDisplayEntryResponse {
|
|||||||
ai?: string;
|
ai?: string;
|
||||||
ec?: number;
|
ec?: number;
|
||||||
en?: string;
|
en?: string;
|
||||||
|
ic?: string;
|
||||||
pl?: string;
|
pl?: string;
|
||||||
tk?: string;
|
tk?: string;
|
||||||
hb?: boolean;
|
hb?: boolean;
|
||||||
|
@ -75,6 +75,9 @@ export const entityIcon = async (hass: HomeAssistant, state: HassEntity) => {
|
|||||||
let icon: string | undefined;
|
let icon: string | undefined;
|
||||||
const domain = computeStateDomain(state);
|
const domain = computeStateDomain(state);
|
||||||
const entity = hass.entities?.[state.entity_id];
|
const entity = hass.entities?.[state.entity_id];
|
||||||
|
if (entity?.icon) {
|
||||||
|
return entity.icon;
|
||||||
|
}
|
||||||
if (entity?.translation_key && entity.platform) {
|
if (entity?.translation_key && entity.platform) {
|
||||||
const platformIcons = await getPlatformIcons(hass, entity.platform);
|
const platformIcons = await getPlatformIcons(hass, entity.platform);
|
||||||
if (platformIcons) {
|
if (platformIcons) {
|
||||||
|
@ -239,6 +239,7 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
|||||||
? entityReg.entity_categories[entity.ec]
|
? entityReg.entity_categories[entity.ec]
|
||||||
: undefined,
|
: undefined,
|
||||||
name: entity.en,
|
name: entity.en,
|
||||||
|
icon: entity.ic,
|
||||||
hidden: entity.hb,
|
hidden: entity.hb,
|
||||||
display_precision: entity.dp,
|
display_precision: entity.dp,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user