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
4 changes: 2 additions & 2 deletions demo/src/custom-cards/cast-demo-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {

import "../../../src/components/ha-icon";
import {
EntityRow,
LovelaceRow,
CastConfig,
} from "../../../src/panels/lovelace/entity-rows/types";
import { HomeAssistant } from "../../../src/types";
import { CastManager } from "../../../src/cast/cast_manager";
import { castSendShowDemo } from "../../../src/cast/receiver_messages";

@customElement("cast-demo-row")
class CastDemoRow extends LitElement implements EntityRow {
class CastDemoRow extends LitElement implements LovelaceRow {
public hass!: HomeAssistant;

@property() private _castManager?: CastManager | null;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/cards/hui-entities-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "../../../components/ha-card";
import "../components/hui-entities-toggle";

import { HomeAssistant } from "../../../types";
import { EntityRow } from "../entity-rows/types";
import { LovelaceRow } from "../entity-rows/types";
import { LovelaceCard, LovelaceCardEditor } from "../types";
import { processConfigEntities } from "../common/process-config-entities";
import { createRowElement } from "../common/create-row-element";
Expand Down Expand Up @@ -41,7 +41,7 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
this._hass = hass;
this.shadowRoot!.querySelectorAll("#states > div > *").forEach(
(element: unknown) => {
(element as EntityRow).hass = hass;
(element as LovelaceRow).hass = hass;
}
);
const entitiesToggle = this.shadowRoot!.querySelector(
Expand Down
10 changes: 6 additions & 4 deletions src/panels/lovelace/common/create-row-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ import "../entity-rows/hui-text-entity-row";
import "../entity-rows/hui-timer-entity-row";
import "../entity-rows/hui-toggle-entity-row";
import "../special-rows/hui-call-service-row";
import "../special-rows/hui-conditional-row";
import "../special-rows/hui-divider-row";
import "../special-rows/hui-section-row";
import "../special-rows/hui-weblink-row";
import "../special-rows/hui-cast-row";
import { EntityConfig, EntityRow } from "../entity-rows/types";
import { EntityConfig, LovelaceRow } from "../entity-rows/types";

const CUSTOM_TYPE_PREFIX = "custom:";
const SPECIAL_TYPES = new Set([
"call-service",
"conditional",
"divider",
"section",
"weblink",
Expand Down Expand Up @@ -69,8 +71,8 @@ const TIMEOUT = 2000;
const _createElement = (
tag: string,
config: EntityConfig
): EntityRow | HuiErrorCard => {
const element = document.createElement(tag) as EntityRow;
): LovelaceRow | HuiErrorCard => {
const element = document.createElement(tag) as LovelaceRow;
try {
element.setConfig(deepClone(config));
} catch (err) {
Expand All @@ -96,7 +98,7 @@ const _hideErrorElement = (element) => {

export const createRowElement = (
config: EntityConfig
): EntityRow | HuiErrorCard => {
): LovelaceRow | HuiErrorCard => {
let tag;

if (
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-climate-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import "../components/hui-generic-entity-row";
import "../components/hui-warning";

import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-climate-entity-row")
class HuiClimateEntityRow extends LitElement implements EntityRow {
class HuiClimateEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-cover-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import "../components/hui-warning";

import { isTiltOnly } from "../../../util/cover-model";
import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-cover-entity-row")
class HuiCoverEntityRow extends LitElement implements EntityRow {
class HuiCoverEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-group-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import "../components/hui-warning";
import { computeStateDisplay } from "../../../common/entity/compute_state_display";
import { DOMAINS_TOGGLE } from "../../../common/const";
import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-group-entity-row")
class HuiGroupEntityRow extends LitElement implements EntityRow {
class HuiGroupEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import "../../../components/ha-date-input";
import { HaDateInput } from "../../../components/ha-date-input";

import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { setInputDateTimeValue } from "../../../data/input_datetime";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-input-datetime-entity-row")
class HuiInputDatetimeEntityRow extends LitElement implements EntityRow {
class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;
@property() private _config?: EntityConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import "../../../components/ha-slider";
import "../components/hui-warning";

import { computeRTLDirection } from "../../../common/util/compute_rtl";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { HomeAssistant } from "../../../types";
import { setValue } from "../../../data/input_text";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-input-number-entity-row")
class HuiInputNumberEntityRow extends LitElement implements EntityRow {
class HuiInputNumberEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import "../components/hui-warning";
import { computeStateName } from "../../../common/entity/compute_state_name";

import { HomeAssistant, InputSelectEntity } from "../../../types";
import { EntityRow } from "./types";
import { LovelaceRow } from "./types";
import { setInputSelectOption } from "../../../data/input-select";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { forwardHaptic } from "../../../data/haptics";
Expand All @@ -33,7 +33,7 @@ import { ActionHandlerEvent } from "../../../data/lovelace";
import { handleAction } from "../common/handle-action";

@customElement("hui-input-select-entity-row")
class HuiInputSelectEntityRow extends LitElement implements EntityRow {
class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntitiesCardEntityConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import "../components/hui-generic-entity-row";
import "../components/hui-warning";

import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { setValue } from "../../../data/input_text";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-input-text-entity-row")
class HuiInputTextEntityRow extends LitElement implements EntityRow {
class HuiInputTextEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-lock-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import "../components/hui-generic-entity-row";
import "../components/hui-warning";

import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-lock-entity-row")
class HuiLockEntityRow extends LitElement implements EntityRow {
class HuiLockEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "@polymer/paper-icon-button/paper-icon-button";
import "../components/hui-generic-entity-row";
import "../components/hui-warning";

import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { HomeAssistant } from "../../../types";
import { HassEntity } from "home-assistant-js-websocket";
import { supportsFeature } from "../../../common/entity/supports-feature";
Expand All @@ -26,7 +26,7 @@ import {
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-media-player-entity-row")
class HuiMediaPlayerEntityRow extends LitElement implements EntityRow {
class HuiMediaPlayerEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-scene-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import "../../../components/entity/ha-entity-toggle";
import "../components/hui-warning";

import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-scene-entity-row")
class HuiSceneEntityRow extends LitElement implements EntityRow {
class HuiSceneEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-script-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import "../../../components/entity/ha-entity-toggle";
import "../components/hui-warning";

import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-script-entity-row")
class HuiScriptEntityRow extends LitElement implements EntityRow {
class HuiScriptEntityRow extends LitElement implements LovelaceRow {
public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import "../components/hui-timestamp-display";
import "../components/hui-warning";

import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { computeStateDisplay } from "../../../common/entity/compute_state_display";

Expand All @@ -23,7 +23,7 @@ interface SensorEntityConfig extends EntityConfig {
}

@customElement("hui-sensor-entity-row")
class HuiSensorEntityRow extends LitElement implements EntityRow {
class HuiSensorEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: SensorEntityConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-text-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import "../components/hui-warning";

import { computeStateDisplay } from "../../../common/entity/compute_state_display";
import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-text-entity-row")
class HuiTextEntityRow extends LitElement implements EntityRow {
class HuiTextEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-toggle-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import "../components/hui-warning";

import { computeStateDisplay } from "../../../common/entity/compute_state_display";
import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { LovelaceRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";

@customElement("hui-toggle-entity-row")
class HuiToggleEntityRow extends LitElement implements EntityRow {
class HuiToggleEntityRow extends LitElement implements LovelaceRow {
@property() public hass?: HomeAssistant;

@property() private _config?: EntityConfig;
Expand Down
8 changes: 7 additions & 1 deletion src/panels/lovelace/entity-rows/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HomeAssistant } from "../../../types";
import { Condition } from "../common/validate-condition";

export interface EntityConfig {
entity: string;
Expand Down Expand Up @@ -30,6 +31,11 @@ export interface CallServiceConfig extends EntityConfig {
service: string;
service_data?: { [key: string]: any };
}
export interface ConditionalRowConfig extends EntityConfig {
type: "conditional";
row: EntityRowConfig;
conditions: Condition[];
}
export interface CastConfig {
type: "cast";
icon: string;
Expand All @@ -46,7 +52,7 @@ export type EntityRowConfig =
| CallServiceConfig
| CastConfig;

export interface EntityRow extends HTMLElement {
export interface LovelaceRow extends HTMLElement {
hass?: HomeAssistant;
setConfig(config: EntityRowConfig);
}
4 changes: 2 additions & 2 deletions src/panels/lovelace/special-rows/hui-call-service-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import "@material/mwc-button";
import "../../../components/ha-icon";

import { callService } from "../common/call-service";
import { EntityRow, CallServiceConfig } from "../entity-rows/types";
import { LovelaceRow, CallServiceConfig } from "../entity-rows/types";
import { HomeAssistant } from "../../../types";

@customElement("hui-call-service-row")
class HuiCallServiceRow extends LitElement implements EntityRow {
class HuiCallServiceRow extends LitElement implements LovelaceRow {
public hass?: HomeAssistant;

@property() private _config?: CallServiceConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/special-rows/hui-cast-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "lit-element";
import { classMap } from "lit-html/directives/class-map";

import { EntityRow, CastConfig } from "../entity-rows/types";
import { LovelaceRow, CastConfig } from "../entity-rows/types";
import { HomeAssistant } from "../../../types";

import "../../../components/ha-icon";
Expand All @@ -20,7 +20,7 @@ import {
} from "../../../cast/receiver_messages";

@customElement("hui-cast-row")
class HuiCastRow extends LitElement implements EntityRow {
class HuiCastRow extends LitElement implements LovelaceRow {
public hass!: HomeAssistant;

@property() private _config?: CastConfig;
Expand Down
Loading