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
10 changes: 10 additions & 0 deletions src/data/tasmota.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { HomeAssistant } from "../types";

export const removeTasmotaDeviceEntry = (
hass: HomeAssistant,
deviceId: string
): Promise<void> =>
hass.callWS({
type: "tasmota/device/remove",
device_id: deviceId,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
CSSResult,
customElement,
html,
LitElement,
property,
TemplateResult,
css,
} from "lit-element";
import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
import { removeTasmotaDeviceEntry } from "../../../../../../data/tasmota";
import { showConfirmationDialog } from "../../../../../../dialogs/generic/show-dialog-box";
import { haStyle } from "../../../../../../resources/styles";
import { HomeAssistant } from "../../../../../../types";

@customElement("ha-device-actions-tasmota")
export class HaDeviceActionsTasmota extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property() public device!: DeviceRegistryEntry;

protected render(): TemplateResult {
return html`
<mwc-button class="warning" @click="${this._confirmDeleteEntry}">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<mwc-button class="warning" @click="${this._confirmDeleteEntry}">
<mwc-button class="warning" @click=${this._confirmDeleteEntry}>

${this.hass.localize("ui.panel.config.devices.delete")}
</mwc-button>
`;
}

private async _confirmDeleteEntry(): Promise<void> {
const confirmed = await showConfirmationDialog(this, {
text: this.hass.localize("ui.panel.config.devices.confirm_delete"),
});

if (!confirmed) {
return;
}

await removeTasmotaDeviceEntry(this.hass!, this.device.id);
}

static get styles(): CSSResult[] {
return [
haStyle,
css`
:host {
display: flex;
justify-content: space-between;
}
`,
];
}
}
13 changes: 13 additions & 0 deletions src/panels/config/devices/ha-config-device-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,19 @@ export class HaConfigDevicePage extends LitElement {
</div>
`);
}
if (integrations.includes("tasmota")) {
import(
"./device-detail/integration-elements/tasmota/ha-device-actions-tasmota"
);
templates.push(html`
<div class="card-actions" slot="actions">
<ha-device-actions-tasmota
.hass=${this.hass}
.device=${device}
></ha-device-actions-tasmota>
</div>
`);
}
if (integrations.includes("zha")) {
import("./device-detail/integration-elements/zha/ha-device-actions-zha");
import("./device-detail/integration-elements/zha/ha-device-info-zha");
Expand Down