diff --git a/src/panels/config/devices/device-detail/ha-device-entities-card.ts b/src/panels/config/devices/device-detail/ha-device-entities-card.ts index 1cfc9d90a6..0c57f498ce 100644 --- a/src/panels/config/devices/device-detail/ha-device-entities-card.ts +++ b/src/panels/config/devices/device-detail/ha-device-entities-card.ts @@ -105,14 +105,8 @@ export class HaDeviceEntitiesCard extends LitElement { ` : html` -
- -
- ${this.hass.localize( - "ui.panel.config.devices.entities.none" - )} -
-
+
+ ${this.hass.localize("ui.panel.config.devices.entities.none")}
`} @@ -228,6 +222,9 @@ export class HaDeviceEntitiesCard extends LitElement { .name { font-size: 14px; } + .empty { + text-align: center; + } button.show-more { color: var(--primary-color); text-align: left; diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index 612a01cfcc..5a2d375d53 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -52,6 +52,7 @@ import { loadDeviceRegistryDetailDialog, showDeviceRegistryDetailDialog, } from "./device-registry-detail/show-dialog-device-registry-detail"; +import { computeDomain } from "../../../common/entity/compute_domain"; export interface EntityRegistryStateEntry extends EntityRegistryEntry { stateName?: string | null; @@ -117,14 +118,19 @@ export class HaConfigDevicePage extends LitElement { private _entitiesByCategory = memoizeOne( (entities: EntityRegistryEntry[]) => { - const result = groupBy( - entities, - (entry) => entry.entity_category || "state" + const result = groupBy(entities, (entry) => + entry.entity_category + ? entry.entity_category + : ["sensor", "binary_sensor"].includes(computeDomain(entry.entity_id)) + ? "sensor" + : "control" ) as Record< - "state" | NonNullable, + | "control" + | "sensor" + | NonNullable, EntityRegistryStateEntry[] >; - for (const key of ["state", "diagnostic", "config"]) { + for (const key of ["control", "sensor", "diagnostic", "config"]) { if (!(key in result)) { result[key] = []; } @@ -351,11 +357,13 @@ export class HaConfigDevicePage extends LitElement { } ${this._renderIntegrationInfo(device, integrations)} - - ${["state", "config", "diagnostic"].map((category) => - !entitiesByCategory[category].length - ? "" - : html` +
+
+ ${["control", "sensor", "config", "diagnostic"].map((category) => + // Make sure we render controls if no other cards will be rendered + entitiesByCategory[category].length > 0 || + (entities.length === 0 && category === "control") + ? html` ` + : "" )} -
-
+
${ isComponentLoaded(this.hass, "automation") ? html` @@ -443,86 +451,76 @@ export class HaConfigDevicePage extends LitElement { ` : "" } -
-
${ isComponentLoaded(this.hass, "scene") && entities.length ? html` -

- ${this.hass.localize( - "ui.panel.config.devices.scene.scenes" - )} +

+ ${this.hass.localize( + "ui.panel.config.devices.scene.scenes" + )} - -

+ + - ${ - this._related?.scene?.length - ? this._related.scene.map((scene) => { - const entityState = this.hass.states[scene]; - return entityState - ? html` -
- - - - ${computeStateName(entityState)} - - - - - ${!entityState.attributes.id - ? html` - - ${this.hass.localize( - "ui.panel.config.devices.cant_edit" - )} - - ` - : ""} -
- ` - : ""; - }) - : html` -
- ${this.hass.localize( - "ui.panel.config.devices.add_prompt", - "name", - this.hass.localize( - "ui.panel.config.devices.scene.scenes" - ) - )} -
- ` - } -
+ ${this._related?.scene?.length + ? this._related.scene.map((scene) => { + const entityState = this.hass.states[scene]; + return entityState + ? html` +
+ + + + ${computeStateName(entityState)} + + + + + ${!entityState.attributes.id + ? html` + + ${this.hass.localize( + "ui.panel.config.devices.cant_edit" + )} + + ` + : ""} +
+ ` + : ""; + }) + : html` +
+ ${this.hass.localize( + "ui.panel.config.devices.add_prompt", + "name", + this.hass.localize( + "ui.panel.config.devices.scene.scenes" + ) + )} +
+ `} ` : "" @@ -582,7 +580,7 @@ export class HaConfigDevicePage extends LitElement { : "" }
-
+ `; } diff --git a/src/translations/en.json b/src/translations/en.json index 98a3b73d8c..e0ff0ec0a4 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2175,9 +2175,10 @@ "device_not_found": "Device not found.", "entities": { "entities": "Entities", - "state": "State", + "control": "Controls", + "sensor": "Sensors", "diagnostic": "Diagnostic", - "config": "Config", + "config": "Configuration", "add_entities_lovelace": "Add to Lovelace", "none": "This device has no entities", "hide_disabled": "Hide disabled",