/** * @license * Copyright 2025-2026 Open Home Foundation * SPDX-License-Identifier: Apache-2.0 */ import "@material/web/button/filled-button"; import "@material/web/button/outlined-button"; import "@material/web/button/text-button"; import "@material/web/divider/divider"; import "@material/web/iconbutton/icon-button"; import "@material/web/list/list"; import "@material/web/list/list-item"; import { consume } from "@lit/context"; import { MatterClient } from "@matter-server/ws-client"; import { mdiFile, mdiPlus } from "@mdi/js"; import { LitElement, css, html, nothing } from "lit"; import { customElement } from "lit/decorators.js"; import { clientContext, tickContext } from "../../client/client-context.js"; import { showAlertDialog, showPromptDialog } from "../../components/dialog-box/show-dialog-box.js"; import { showCommissionNodeDialog } from "../../components/dialogs/commission-node-dialog/show-commission-node-dialog.js"; import "../../components/ha-svg-icon"; import { handleAsync } from "../../util/async-handler.js"; @customElement("server-details") export class ServerDetails extends LitElement { @consume({ context: clientContext }) public client?: MatterClient; @consume({ context: tickContext, subscribe: true }) protected _tick = 0; protected override render() { if (!this.client) return html``; return html`
Open Home Foundation Matter Server ${this.client.isProduction ? "" : `(${this.client.serverBaseAddress})`} ${this.client.connection.connected ? nothing : html` OFFLINE `}
Matter Server Version:
${this.client.serverInfo.sdk_version}
FabricId:
${this.client.serverInfo.fabric_id}
Compressed FabricId:
${this.client.serverInfo.compressed_fabric_id}
Schema Version:
${this.client.serverInfo.schema_version}
Node count:
${Object.keys(this.client.nodes).length}
Commission node this._uploadDiagnosticsDumpFile())}>Import node
`; } private _commissionNode() { showCommissionNodeDialog(); } private async _uploadDiagnosticsDumpFile() { if ( !(await showPromptDialog({ title: "Add test node", text: "Do you want to add a test node from a diagnostics dump ?", confirmText: "Select file", })) ) { return; } const fileElem = this.shadowRoot!.getElementById("fileElem") as HTMLInputElement; fileElem.click(); } private _onFileInput = (event: Event) => { const fileElem = event.target as HTMLInputElement; if (fileElem.files!.length > 0) { const selectedFile = fileElem.files![0]; const reader = new FileReader(); reader.readAsText(selectedFile, "UTF-8"); reader.onload = async () => { try { await this.client?.importTestNode(reader.result?.toString() ?? ""); } catch (err: any) { showAlertDialog({ title: "Failed to import test node", text: err.message, }); } finally { fileElem.value = ""; } }; } event.preventDefault(); }; static override styles = css` .btn-row { --md-outlined-button-container-shape: 0px; display: flex; flex-wrap: wrap; gap: 8px; } .btn-row md-outlined-button { max-width: 100%; } .left { min-width: 120px; display: inline-block; } @media (min-width: 600px) { .left { min-width: 160px; } } .whitespace { height: 15px; } .status { color: var(--danger-color); font-weight: bold; font-size: 0.8em; } `; }