Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions src/panels/lovelace/cards/hui-entities-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -149,22 +145,16 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
element.hass = this._hass;
}
if (
entityConf.entity &&
!DOMAINS_HIDE_MORE_INFO.includes(computeDomain(entityConf.entity))
!entityConf.tap_action ||
(entityConf.tap_action && entityConf.tap_action.action !== "none")
) {
element.classList.add("state-card-dialog");
element.addEventListener("click", () => this._handleClick(entityConf));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now changed the behaviour of all entity rows? You can no longer click on the row to get the more-info?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved actions to the badge

}

return html`
<div>${element}</div>
`;
}

private _handleClick(entityConf: EntitiesCardEntityConfig): void {
const entityId = entityConf.entity;
fireEvent(this, "hass-more-info", { entityId });
}
}

declare global {
Expand Down
2 changes: 2 additions & 0 deletions src/panels/lovelace/cards/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export interface EntitiesCardEntityConfig extends EntityConfig {
service?: string;
service_data?: object;
url?: string;
tap_action?: ActionConfig;
hold_action?: ActionConfig;
}

export interface EntitiesCardConfig extends LovelaceCardConfig {
Expand Down
2 changes: 2 additions & 0 deletions src/panels/lovelace/editor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]);
18 changes: 17 additions & 1 deletion src/panels/lovelace/entity-rows/hui-climate-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import "../components/hui-warning";
import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { longPress } from "../common/directives/long-press-directive";
import { handleClick } from "../common/handle-click";

@customElement("hui-climate-entity-row")
class HuiClimateEntityRow extends LitElement implements EntityRow {
Expand Down Expand Up @@ -55,7 +57,13 @@ class HuiClimateEntityRow extends LitElement implements EntityRow {
}

return html`
<hui-generic-entity-row .hass="${this.hass}" .config="${this._config}">
<hui-generic-entity-row
@ha-click=${this._handleTap}
Comment thread
iantrich marked this conversation as resolved.
Outdated
@ha-hold=${this._handleHold}
.longPress=${longPress()}
.hass=${this.hass}
.config=${this._config}
>
<ha-climate-state
.hass="${this.hass}"
.stateObj="${stateObj}"
Expand All @@ -71,6 +79,14 @@ class HuiClimateEntityRow extends LitElement implements EntityRow {
}
`;
}

private _handleTap() {
handleClick(this, this.hass!, this._config!, false);
}

private _handleHold() {
handleClick(this, this.hass!, this._config!, true);
}
}

declare global {
Expand Down
18 changes: 17 additions & 1 deletion src/panels/lovelace/entity-rows/hui-cover-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { isTiltOnly } from "../../../util/cover-model";
import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { longPress } from "../common/directives/long-press-directive";
import { handleClick } from "../common/handle-click";

@customElement("hui-cover-entity-row")
class HuiCoverEntityRow extends LitElement implements EntityRow {
Expand Down Expand Up @@ -56,7 +58,13 @@ class HuiCoverEntityRow extends LitElement implements EntityRow {
}

return html`
<hui-generic-entity-row .hass="${this.hass}" .config="${this._config}">
<hui-generic-entity-row
@ha-click=${this._handleTap}
@ha-hold=${this._handleHold}
.longPress=${longPress()}
.hass=${this.hass}
.config=${this._config}
>
${isTiltOnly(stateObj)
? html`
<ha-cover-tilt-controls
Expand All @@ -82,6 +90,14 @@ class HuiCoverEntityRow extends LitElement implements EntityRow {
}
`;
}

private _handleTap() {
handleClick(this, this.hass!, this._config!, false);
}

private _handleHold() {
handleClick(this, this.hass!, this._config!, true);
}
}

declare global {
Expand Down
18 changes: 17 additions & 1 deletion src/panels/lovelace/entity-rows/hui-group-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { DOMAINS_TOGGLE } from "../../../common/const";
import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { longPress } from "../common/directives/long-press-directive";
import { handleClick } from "../common/handle-click";

@customElement("hui-group-entity-row")
class HuiGroupEntityRow extends LitElement implements EntityRow {
Expand Down Expand Up @@ -54,7 +56,13 @@ class HuiGroupEntityRow extends LitElement implements EntityRow {
}

return html`
<hui-generic-entity-row .hass="${this.hass}" .config="${this._config}">
<hui-generic-entity-row
@ha-click=${this._handleTap}
@ha-hold=${this._handleHold}
.longPress=${longPress()}
.hass=${this.hass}
.config=${this._config}
>
${this._computeCanToggle(stateObj.attributes.entity_id)
? html`
<ha-entity-toggle
Expand All @@ -80,6 +88,14 @@ class HuiGroupEntityRow extends LitElement implements EntityRow {
DOMAINS_TOGGLE.has(entityId.split(".", 1)[0])
);
}

private _handleTap() {
handleClick(this, this.hass!, this._config!, false);
}

private _handleHold() {
handleClick(this, this.hass!, this._config!, true);
}
}

declare global {
Expand Down
18 changes: 17 additions & 1 deletion src/panels/lovelace/entity-rows/hui-input-datetime-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { setInputDateTimeValue } from "../../../data/input_datetime";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { longPress } from "../common/directives/long-press-directive";
import { handleClick } from "../common/handle-click";

@customElement("hui-input-datetime-entity-row")
class HuiInputDatetimeEntityRow extends LitElement implements EntityRow {
Expand Down Expand Up @@ -56,7 +58,13 @@ class HuiInputDatetimeEntityRow extends LitElement implements EntityRow {
}

return html`
<hui-generic-entity-row .hass="${this.hass}" .config="${this._config}">
<hui-generic-entity-row
@ha-click=${this._handleTap}
@ha-hold=${this._handleHold}
.longPress=${longPress()}
.hass=${this.hass}
.config=${this._config}
>
${stateObj.attributes.has_date
? html`
<ha-date-input
Expand Down Expand Up @@ -119,6 +127,14 @@ class HuiInputDatetimeEntityRow extends LitElement implements EntityRow {

ev.target.blur();
}

private _handleTap() {
handleClick(this, this.hass!, this._config!, false);
}

private _handleHold() {
handleClick(this, this.hass!, this._config!, true);
}
}

declare global {
Expand Down
18 changes: 17 additions & 1 deletion src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { EntityRow, EntityConfig } from "./types";
import { HomeAssistant } from "../../../types";
import { setValue } from "../../../data/input_text";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { longPress } from "../common/directives/long-press-directive";
import { handleClick } from "../common/handle-click";

@customElement("hui-input-number-entity-row")
class HuiInputNumberEntityRow extends LitElement implements EntityRow {
Expand Down Expand Up @@ -74,7 +76,13 @@ class HuiInputNumberEntityRow extends LitElement implements EntityRow {
}

return html`
<hui-generic-entity-row .hass="${this.hass}" .config="${this._config}">
<hui-generic-entity-row
@ha-click=${this._handleTap}
@ha-hold=${this._handleHold}
.longPress=${longPress()}
.hass=${this.hass}
.config=${this._config}
>
<div>
${stateObj.attributes.mode === "slider"
? html`
Expand Down Expand Up @@ -158,6 +166,14 @@ class HuiInputNumberEntityRow extends LitElement implements EntityRow {
setValue(this.hass!, stateObj.entity_id, element.value!);
}
}

private _handleTap() {
handleClick(this, this.hass!, this._config!, false);
}

private _handleHold() {
handleClick(this, this.hass!, this._config!, true);
}
}

declare global {
Expand Down
19 changes: 17 additions & 2 deletions src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -64,7 +66,12 @@ class HuiInputSelectEntityRow extends LitElement implements EntityRow {
}

return html`
<state-badge .stateObj="${stateObj}"></state-badge>
<state-badge
@ha-click="${this._handleTap}"
@ha-hold="${this._handleHold}"
.longPress="${longPress()}"
.stateObj="${stateObj}"
></state-badge>
<ha-paper-dropdown-menu
.label=${this._config.name || computeStateName(stateObj)}
.value=${stateObj.state}
Expand Down Expand Up @@ -132,6 +139,14 @@ class HuiInputSelectEntityRow extends LitElement implements EntityRow {

setInputSelectOption(this.hass!, stateObj.entity_id, option);
}

private _handleTap() {
handleClick(this, this.hass!, this._config!, false);
}

private _handleHold() {
handleClick(this, this.hass!, this._config!, true);
}
}

declare global {
Expand Down
18 changes: 17 additions & 1 deletion src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { setValue } from "../../../data/input_text";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { longPress } from "../common/directives/long-press-directive";
import { handleClick } from "../common/handle-click";

@customElement("hui-input-text-entity-row")
class HuiInputTextEntityRow extends LitElement implements EntityRow {
Expand Down Expand Up @@ -53,7 +55,13 @@ class HuiInputTextEntityRow extends LitElement implements EntityRow {
}

return html`
<hui-generic-entity-row .hass="${this.hass}" .config="${this._config}">
<hui-generic-entity-row
@ha-click=${this._handleTap}
@ha-hold=${this._handleHold}
.longPress=${longPress()}
.hass=${this.hass}
.config=${this._config}
>
<paper-input
no-label-float
.value="${stateObj.state}"
Expand Down Expand Up @@ -83,6 +91,14 @@ class HuiInputTextEntityRow extends LitElement implements EntityRow {

ev.target.blur();
}

private _handleTap() {
handleClick(this, this.hass!, this._config!, false);
}

private _handleHold() {
handleClick(this, this.hass!, this._config!, true);
}
}

declare global {
Expand Down
18 changes: 17 additions & 1 deletion src/panels/lovelace/entity-rows/hui-lock-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import "../components/hui-warning";
import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { longPress } from "../common/directives/long-press-directive";
import { handleClick } from "../common/handle-click";

@customElement("hui-lock-entity-row")
class HuiLockEntityRow extends LitElement implements EntityRow {
Expand Down Expand Up @@ -53,7 +55,13 @@ class HuiLockEntityRow extends LitElement implements EntityRow {
}

return html`
<hui-generic-entity-row .hass="${this.hass}" .config="${this._config}">
<hui-generic-entity-row
@ha-click=${this._handleTap}
@ha-hold=${this._handleHold}
.longPress=${longPress()}
.hass=${this.hass}
.config=${this._config}
>
<mwc-button @click="${this._callService}">
${stateObj.state === "locked"
? this.hass!.localize("ui.card.lock.unlock")
Expand All @@ -80,6 +88,14 @@ class HuiLockEntityRow extends LitElement implements EntityRow {
{ entity_id: stateObj.entity_id }
);
}

private _handleTap() {
handleClick(this, this.hass!, this._config!, false);
}

private _handleHold() {
handleClick(this, this.hass!, this._config!, true);
}
}

declare global {
Expand Down
Loading