diff --git a/src/data/tasmota.ts b/src/data/tasmota.ts new file mode 100644 index 0000000000..df9aad3032 --- /dev/null +++ b/src/data/tasmota.ts @@ -0,0 +1,10 @@ +import { HomeAssistant } from "../types"; + +export const removeTasmotaDeviceEntry = ( + hass: HomeAssistant, + deviceId: string +): Promise => + hass.callWS({ + type: "tasmota/device/remove", + device_id: deviceId, + }); diff --git a/src/panels/config/devices/device-detail/integration-elements/tasmota/ha-device-actions-tasmota.ts b/src/panels/config/devices/device-detail/integration-elements/tasmota/ha-device-actions-tasmota.ts new file mode 100644 index 0000000000..c83d785fdd --- /dev/null +++ b/src/panels/config/devices/device-detail/integration-elements/tasmota/ha-device-actions-tasmota.ts @@ -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` + + ${this.hass.localize("ui.panel.config.devices.delete")} + + `; + } + + private async _confirmDeleteEntry(): Promise { + 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; + } + `, + ]; + } +} diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index c1072e6b29..15a471bd6c 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -528,6 +528,19 @@ export class HaConfigDevicePage extends LitElement { `); } + if (integrations.includes("tasmota")) { + import( + "./device-detail/integration-elements/tasmota/ha-device-actions-tasmota" + ); + templates.push(html` +
+ +
+ `); + } if (integrations.includes("zha")) { import("./device-detail/integration-elements/zha/ha-device-actions-zha"); import("./device-detail/integration-elements/zha/ha-device-info-zha");