diff --git a/src/panels/lovelace/cards/hui-entities-card.ts b/src/panels/lovelace/cards/hui-entities-card.ts
index 15f5762029c0..37ed5cb6de95 100644
--- a/src/panels/lovelace/cards/hui-entities-card.ts
+++ b/src/panels/lovelace/cards/hui-entities-card.ts
@@ -12,16 +12,12 @@ import {
import "../../../components/ha-card";
import "../components/hui-entities-toggle";
-import { fireEvent } from "../../../common/dom/fire_event";
-import { DOMAINS_HIDE_MORE_INFO } from "../../../common/const";
import { HomeAssistant } from "../../../types";
import { EntityRow } from "../entity-rows/types";
import { LovelaceCard, LovelaceCardEditor } from "../types";
import { processConfigEntities } from "../common/process-config-entities";
import { createRowElement } from "../common/create-row-element";
import { EntitiesCardConfig, EntitiesCardEntityConfig } from "./types";
-
-import { computeDomain } from "../../../common/entity/compute_domain";
import applyThemesOnElement from "../../../common/dom/apply_themes_on_element";
@customElement("hui-entities-card")
@@ -136,10 +132,6 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
#states > div > * {
overflow: hidden;
}
-
- .state-card-dialog {
- cursor: pointer;
- }
`;
}
@@ -148,23 +140,11 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
if (this._hass) {
element.hass = this._hass;
}
- if (
- entityConf.entity &&
- !DOMAINS_HIDE_MORE_INFO.includes(computeDomain(entityConf.entity))
- ) {
- element.classList.add("state-card-dialog");
- element.addEventListener("click", () => this._handleClick(entityConf));
- }
return html`
@@ -86,6 +98,14 @@ class HuiGenericEntityRow extends LitElement {
}
}
+ private _handleTap() {
+ handleClick(this, this.hass!, this.config!, false);
+ }
+
+ private _handleHold() {
+ handleClick(this, this.hass!, this.config!, true);
+ }
+
static get styles(): CSSResult {
return css`
:host {
@@ -132,6 +152,9 @@ class HuiGenericEntityRow extends LitElement {
margin-left: 0;
margin-right: 8px;
}
+ .pointer {
+ cursor: pointer;
+ }
`;
}
}
diff --git a/src/panels/lovelace/editor/types.ts b/src/panels/lovelace/editor/types.ts
index 42a04fd5dce0..5cb5a5f73902 100644
--- a/src/panels/lovelace/editor/types.ts
+++ b/src/panels/lovelace/editor/types.ts
@@ -62,6 +62,8 @@ export const entitiesConfigStruct = struct.union([
entity: "entity-id",
name: "string?",
icon: "icon?",
+ tap_action: struct.optional(actionConfigStruct),
+ hold_action: struct.optional(actionConfigStruct),
},
"entity-id",
]);
diff --git a/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts b/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts
index 12abfa60ad0f..30c9b1a4d79e 100644
--- a/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts
+++ b/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts
@@ -14,15 +14,17 @@ import "@polymer/paper-listbox/paper-listbox";
import "../../../components/ha-paper-dropdown-menu";
import "../../../components/entity/state-badge";
import "../components/hui-warning";
+import "../components/hui-generic-entity-row";
import { computeStateName } from "../../../common/entity/compute_state_name";
-
import { HomeAssistant, InputSelectEntity } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { setInputSelectOption } from "../../../data/input-select";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { forwardHaptic } from "../../../data/haptics";
import { stopPropagation } from "../../../common/dom/stop_propagation";
+import { longPress } from "../common/directives/long-press-directive";
+import { handleClick } from "../common/handle-click";
@customElement("hui-input-select-entity-row")
class HuiInputSelectEntityRow extends LitElement implements EntityRow {
@@ -64,7 +66,12 @@ class HuiInputSelectEntityRow extends LitElement implements EntityRow {
}
return html`
-
+