Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 5 additions & 4 deletions src/panels/lovelace/entity-rows/hui-scene-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import "../../../components/entity/ha-entity-toggle";
import "../components/hui-warning";

import { HomeAssistant } from "../../../types";
import { LovelaceRow, EntityConfig } from "./types";
import { LovelaceRow, ActionRowConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import { activateScene } from "../../../data/scene";

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

@property() private _config?: EntityConfig;
@property() private _config?: ActionRowConfig;

public setConfig(config: EntityConfig): void {
public setConfig(config: ActionRowConfig): void {
if (!config) {
throw new Error("Configuration error");
}
Expand Down Expand Up @@ -65,7 +65,8 @@ class HuiSceneEntityRow extends LitElement implements LovelaceRow {
`
: html`
<mwc-button @click="${this._callService}">
${this.hass!.localize("ui.card.scene.activate")}
${this._config.action_name ||
this.hass!.localize("ui.card.scene.activate")}
</mwc-button>
`}
</hui-generic-entity-row>
Expand Down
9 changes: 5 additions & 4 deletions src/panels/lovelace/entity-rows/hui-script-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import "../../../components/entity/ha-entity-toggle";
import "../components/hui-warning";

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

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

@property() private _config?: EntityConfig;
@property() private _config?: ActionRowConfig;

public setConfig(config: EntityConfig): void {
public setConfig(config: ActionRowConfig): void {
if (!config) {
throw new Error("Configuration error");
}
Expand Down Expand Up @@ -64,7 +64,8 @@ class HuiScriptEntityRow extends LitElement implements LovelaceRow {
`
: html`
<mwc-button @click="${this._callService}">
${this.hass!.localize("ui.card.script.execute")}
${this._config.action_name ||
this.hass!.localize("ui.card.script.execute")}
</mwc-button>
`}
</hui-generic-entity-row>
Expand Down
3 changes: 3 additions & 0 deletions src/panels/lovelace/entity-rows/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export interface EntityConfig {
icon?: string;
image?: string;
}
export interface ActionRowConfig extends EntityConfig {
action_name?: string;
}
export interface EntityFilterEntityConfig extends EntityConfig {
state_filter?: Array<{ key: string } | string>;
}
Expand Down
6 changes: 4 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 @@ -26,7 +26,7 @@ class HuiCallServiceRow extends LitElement implements LovelaceRow {
throw new Error("Error in card configuration.");
}

this._config = { icon: "hass:remote", action_name: "Run", ...config };
this._config = { icon: "hass:remote", ...config };
}

protected render(): TemplateResult | void {
Expand All @@ -39,7 +39,9 @@ class HuiCallServiceRow extends LitElement implements LovelaceRow {
<div class="flex">
<div>${this._config.name}</div>
<mwc-button @click="${this._callService}"
>${this._config.action_name}</mwc-button
>${this._config.action_name
? this._config.action_name
: this.hass!.localize("ui.card.service.run")}</mwc-button
>
</div>
`;
Expand Down
3 changes: 3 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@
"script": {
"execute": "Execute"
},
"service": {
"run": "Run"
},
"timer": {
"actions": {
"start": "start",
Expand Down