Skip to content

Commit

Permalink
Show icon of disabled entities (#19717)
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya authored and bramkragten committed Feb 8, 2024
1 parent 7bef489 commit eafbcdb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
15 changes: 8 additions & 7 deletions src/panels/config/entities/entity-registry-settings-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import "../../../components/ha-area-picker";
import "../../../components/ha-icon";
import "../../../components/ha-icon-button-next";
import "../../../components/ha-icon-picker";
import "../../../components/ha-state-icon";
import "../../../components/ha-list-item";
import "../../../components/ha-radio";
import "../../../components/ha-select";
import "../../../components/ha-settings-row";
import "../../../components/ha-state-icon";
import "../../../components/ha-switch";
import type { HaSwitch } from "../../../components/ha-switch";
import "../../../components/ha-textfield";
Expand All @@ -52,10 +52,6 @@ import {
createConfigFlow,
handleConfigFlowStep,
} from "../../../data/config_flow";
import {
createOptionsFlow,
handleOptionsFlowStep,
} from "../../../data/options_flow";
import { DataEntryFlowStepCreateEntry } from "../../../data/data_entry_flow";
import {
DeviceRegistryEntry,
Expand All @@ -70,9 +66,13 @@ import {
subscribeEntityRegistry,
updateEntityRegistryEntry,
} from "../../../data/entity_registry";
import { entityIcon } from "../../../data/icons";
import { entityIcon, entryIcon } from "../../../data/icons";
import { domainToName } from "../../../data/integration";
import { getNumberDeviceClassConvertibleUnits } from "../../../data/number";
import {
createOptionsFlow,
handleOptionsFlowStep,
} from "../../../data/options_flow";
import {
getSensorDeviceClassConvertibleUnits,
getSensorNumericDeviceClasses,
Expand Down Expand Up @@ -392,7 +392,8 @@ export class EntityRegistrySettingsEditor extends LitElement {
)}
.placeholder=${this.entry.original_icon ||
stateObj?.attributes.icon ||
(stateObj && until(entityIcon(this.hass, stateObj)))}
(stateObj && until(entityIcon(this.hass, stateObj))) ||
until(entryIcon(this.hass, this.entry))}
.disabled=${this.disabled}
>
${!this._icon && !stateObj?.attributes.icon && stateObj
Expand Down
28 changes: 20 additions & 8 deletions src/panels/config/entities/ha-config-entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { ifDefined } from "lit/directives/if-defined";
import { styleMap } from "lit/directives/style-map";
import { until } from "lit/directives/until";
import memoize from "memoize-one";
import type { HASSDomEvent } from "../../../common/dom/fire_event";
import { computeDomain } from "../../../common/entity/compute_domain";
Expand All @@ -42,6 +43,7 @@ import type {
} from "../../../components/data-table/ha-data-table";
import "../../../components/ha-button-menu";
import "../../../components/ha-check-list-item";
import "../../../components/ha-icon";
import "../../../components/ha-icon-button";
import "../../../components/ha-svg-icon";
import { ConfigEntry, getConfigEntries } from "../../../data/config_entries";
Expand All @@ -53,6 +55,7 @@ import {
removeEntityRegistryEntry,
updateEntityRegistryEntry,
} from "../../../data/entity_registry";
import { entryIcon } from "../../../data/icons";
import { domainToName } from "../../../data/integration";
import {
showAlertDialog,
Expand Down Expand Up @@ -207,14 +210,23 @@ export class HaConfigEntities extends LitElement {
title: "",
label: localize("ui.panel.config.entities.picker.headers.state_icon"),
type: "icon",
template: (entry) => html`
<ha-state-icon
title=${ifDefined(entry.entity?.state)}
slot="item-icon"
.hass=${this.hass}
.stateObj=${entry.entity}
></ha-state-icon>
`,
template: (entry) =>
entry.icon
? html`
<ha-state-icon
title=${ifDefined(entry.entity?.state)}
slot="item-icon"
.hass=${this.hass}
.stateObj=${entry.entity}
></ha-state-icon>
`
: html`
<ha-icon
icon=${until(
entryIcon(this.hass, entry as EntityRegistryEntry)
)}
></ha-icon>
`,
},
name: {
main: true,
Expand Down

0 comments on commit eafbcdb

Please sign in to comment.