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
1 change: 1 addition & 0 deletions src/common/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const DOMAINS_WITH_MORE_INFO = [
"camera",
"climate",
"configurator",
"counter",
"cover",
"fan",
"group",
Expand Down
1 change: 1 addition & 0 deletions src/common/entity/domain_icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const fixedIcons = {
climate: "hass:thermostat",
configurator: "hass:settings",
conversation: "hass:text-to-speech",
counter: "hass:counter",
device_tracker: "hass:account",
fan: "hass:fan",
google_assistant: "hass:google-assistant",
Expand Down
1 change: 1 addition & 0 deletions src/dialogs/more-info/controls/more-info-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "./more-info-automation";
import "./more-info-camera";
import "./more-info-climate";
import "./more-info-configurator";
import "./more-info-counter";
import "./more-info-cover";
import "./more-info-default";
import "./more-info-fan";
Expand Down
70 changes: 70 additions & 0 deletions src/dialogs/more-info/controls/more-info-counter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {
LitElement,
html,
TemplateResult,
CSSResult,
css,
property,
customElement,
} from "lit-element";
import "@material/mwc-button";
import { HassEntity } from "home-assistant-js-websocket";

import { HomeAssistant } from "../../../types";

@customElement("more-info-counter")
class MoreInfoCounter extends LitElement {
@property() public hass!: HomeAssistant;
@property() public stateObj?: HassEntity;

protected render(): TemplateResult | void {
if (!this.hass || !this.stateObj) {
return html``;
}

return html`
<div class="actions">
<mwc-button
.action="${"increment"}"
@click="${this._handleActionClick}"
>
${this.hass!.localize("ui.card.counter.actions.increment")}
</mwc-button>
<mwc-button
.action="${"decrement"}"
@click="${this._handleActionClick}"
>
${this.hass!.localize("ui.card.counter.actions.decrement")}
</mwc-button>
<mwc-button .action="${"reset"}" @click="${this._handleActionClick}">
${this.hass!.localize("ui.card.counter.actions.reset")}
</mwc-button>
</div>
`;
}

private _handleActionClick(e: MouseEvent): void {
const action = (e.currentTarget as any).action;
this.hass.callService("counter", action, {
entity_id: this.stateObj!.entity_id,
});
}

static get styles(): CSSResult {
return css`
.actions {
margin: 0 8px;
padding-top: 20px;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
`;
}
}

declare global {
interface HTMLElementTagNameMap {
"more-info-counter": MoreInfoCounter;
}
}
7 changes: 7 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@
"away_mode": "Away mode",
"aux_heat": "Aux heat"
},
"counter": {
"actions": {
"increment": "increment",
"decrement": "decrement",
"reset": "reset"
}
},
"cover": {
"position": "Position",
"tilt_position": "Tilt position"
Expand Down