/** * @license * Copyright 2025-2026 Open Home Foundation * SPDX-License-Identifier: Apache-2.0 */ import "@material/web/button/text-button"; import "@material/web/dialog/dialog"; import { consume } from "@lit/context"; import "@material/web/list/list"; import "@material/web/list/list-item"; import type { MdDialog } from "@material/web/dialog/dialog.js"; import { MatterClient, MatterNode } from "@matter-server/ws-client"; import { html, LitElement } from "lit"; import { customElement, state } from "lit/decorators.js"; import { clientContext, tickContext } from "../../../client/client-context.js"; import { preventDefault } from "../../../util/prevent_default.js"; @customElement("commission-node-dialog") export class ComissionNodeDialog extends LitElement { @consume({ context: clientContext }) public client!: MatterClient; @consume({ context: tickContext, subscribe: true }) protected _tick = 0; @state() private _mode?: "wifi" | "thread" | "existing"; protected override render() { return html`
Commission node
${!this._mode ? html` Commission new WiFi device Commission new Thread device Commission existing device ` : this._mode === "wifi" ? html` ` : this._mode === "thread" ? html` ` : html` `}
Cancel
`; } private _commissionWifi() { if (!this.client.serverInfo.bluetooth_enabled) { return; } import("./commission-node-wifi.js"); this._mode = "wifi"; } private _commissionThread() { if (!this.client.serverInfo.bluetooth_enabled) { return; } import("./commission-node-thread.js"); this._mode = "thread"; } private _commissionExisting() { import("./commission-node-existing.js"); this._mode = "existing"; } private _nodeCommissioned(ev: CustomEvent) { window.location.href = `#node/${ev.detail.node_id}`; this._close(); } private _requestSettings() { import("../settings/show-settings-dialog.js").then(({ showSettingsDialog }) => { showSettingsDialog("network-credentials"); }); this._close(); } private _close() { this.shadowRoot!.querySelector("md-dialog")!.close(); } private _handleClosed() { this.parentNode!.removeChild(this); } } declare global { interface HTMLElementTagNameMap { "commission-node-dialog": ComissionNodeDialog; } interface HASSDomEvents { "node-commissioned": MatterNode; "request-settings": Record; } }