mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 17:56:46 +00:00
Add custom device action to remove a Tasmota device (#7469)
This commit is contained in:
parent
ba4c2fc1bd
commit
bf98a78f3d
10
src/data/tasmota.ts
Normal file
10
src/data/tasmota.ts
Normal file
@ -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,
|
||||||
|
});
|
@ -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}">
|
||||||
|
${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;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -528,6 +528,19 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
</div>
|
</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")) {
|
if (integrations.includes("zha")) {
|
||||||
import("./device-detail/integration-elements/zha/ha-device-actions-zha");
|
import("./device-detail/integration-elements/zha/ha-device-actions-zha");
|
||||||
import("./device-detail/integration-elements/zha/ha-device-info-zha");
|
import("./device-detail/integration-elements/zha/ha-device-info-zha");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user