mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add initial Thread panel (#15126)
* Add initial Thread panel * Add link to Matter panel
This commit is contained in:
parent
c7f4693f0a
commit
558f523207
11
src/data/thread.ts
Normal file
11
src/data/thread.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { HomeAssistant } from "../types";
|
||||||
|
|
||||||
|
export interface ThreadInfo {
|
||||||
|
url: string;
|
||||||
|
active_dataset_tlvs: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const threadGetInfo = (hass: HomeAssistant): Promise<ThreadInfo> =>
|
||||||
|
hass.callWS({
|
||||||
|
type: "otbr/info",
|
||||||
|
});
|
@ -485,6 +485,13 @@ class HaPanelConfig extends HassRouterPage {
|
|||||||
"./integrations/integration-panels/matter/matter-config-panel"
|
"./integrations/integration-panels/matter/matter-config-panel"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
thread: {
|
||||||
|
tag: "thread-config-panel",
|
||||||
|
load: () =>
|
||||||
|
import(
|
||||||
|
"./integrations/integration-panels/thread/thread-config-panel"
|
||||||
|
),
|
||||||
|
},
|
||||||
application_credentials: {
|
application_credentials: {
|
||||||
tag: "ha-config-application-credentials",
|
tag: "ha-config-application-credentials",
|
||||||
load: () =>
|
load: () =>
|
||||||
|
@ -79,6 +79,7 @@ const integrationsWithPanel = {
|
|||||||
zha: "/config/zha/dashboard",
|
zha: "/config/zha/dashboard",
|
||||||
zwave_js: "/config/zwave_js/dashboard",
|
zwave_js: "/config/zwave_js/dashboard",
|
||||||
matter: "/config/matter",
|
matter: "/config/matter",
|
||||||
|
otbr: "/config/thread",
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("ha-integration-card")
|
@customElement("ha-integration-card")
|
||||||
|
@ -14,6 +14,7 @@ import { HomeAssistant } from "../../../../../types";
|
|||||||
import "../../../../../components/ha-alert";
|
import "../../../../../components/ha-alert";
|
||||||
import { showPromptDialog } from "../../../../../dialogs/generic/show-dialog-box";
|
import { showPromptDialog } from "../../../../../dialogs/generic/show-dialog-box";
|
||||||
import { navigate } from "../../../../../common/navigate";
|
import { navigate } from "../../../../../common/navigate";
|
||||||
|
import { isComponentLoaded } from "../../../../../common/config/is_component_loaded";
|
||||||
|
|
||||||
@customElement("matter-config-panel")
|
@customElement("matter-config-panel")
|
||||||
export class MatterConfigPanel extends LitElement {
|
export class MatterConfigPanel extends LitElement {
|
||||||
@ -32,18 +33,24 @@ export class MatterConfigPanel extends LitElement {
|
|||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<hass-subpage .narrow=${this.narrow} .hass=${this.hass} header="Matter">
|
<hass-subpage .narrow=${this.narrow} .hass=${this.hass} header="Matter">
|
||||||
|
${isComponentLoaded(this.hass, "otbr")
|
||||||
|
? html`
|
||||||
|
<a href="/config/thread" slot="toolbar-icon">
|
||||||
|
<mwc-button>Visit Thread Panel</mwc-button>
|
||||||
|
</a>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ha-card header="Matter">
|
<ha-card header="Matter">
|
||||||
|
<ha-alert alert-type="warning"
|
||||||
|
>Matter is still in the early phase of development, it is not
|
||||||
|
meant to be used in production. This panel is for development
|
||||||
|
only.</ha-alert
|
||||||
|
>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${this._error
|
${this._error
|
||||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||||
: ""}
|
: ""}
|
||||||
<ha-alert alert-type="warning"
|
|
||||||
>Matter is still in the early phase of development, it is not
|
|
||||||
meant to be used in production. This panel is for development
|
|
||||||
only.</ha-alert
|
|
||||||
>
|
|
||||||
|
|
||||||
You can add Matter devices by commissing them if they are not
|
You can add Matter devices by commissing them if they are not
|
||||||
setup yet, or share them from another controller and enter the
|
setup yet, or share them from another controller and enter the
|
||||||
share code.
|
share code.
|
||||||
@ -199,6 +206,10 @@ export class MatterConfigPanel extends LitElement {
|
|||||||
static styles = [
|
static styles = [
|
||||||
haStyle,
|
haStyle,
|
||||||
css`
|
css`
|
||||||
|
ha-alert[alert-type="warning"] {
|
||||||
|
position: relative;
|
||||||
|
top: -16px;
|
||||||
|
}
|
||||||
.content {
|
.content {
|
||||||
padding: 24px 0 32px;
|
padding: 24px 0 32px;
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
@ -208,6 +219,9 @@ export class MatterConfigPanel extends LitElement {
|
|||||||
ha-card:first-child {
|
ha-card:first-child {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
a[slot="toolbar-icon"] {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
import "@material/mwc-button";
|
||||||
|
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||||
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import "../../../../../components/ha-card";
|
||||||
|
import "../../../../../layouts/hass-subpage";
|
||||||
|
import { haStyle } from "../../../../../resources/styles";
|
||||||
|
import { HomeAssistant } from "../../../../../types";
|
||||||
|
import { threadGetInfo, ThreadInfo } from "../../../../../data/thread";
|
||||||
|
|
||||||
|
@customElement("thread-config-panel")
|
||||||
|
export class ThreadConfigPanel extends LitElement {
|
||||||
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public narrow!: boolean;
|
||||||
|
|
||||||
|
@state() private _info?: ThreadInfo;
|
||||||
|
|
||||||
|
protected render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<hass-subpage .narrow=${this.narrow} .hass=${this.hass} header="Thread">
|
||||||
|
<div class="content">
|
||||||
|
<ha-card header="Thread Border Router">
|
||||||
|
<div class="card-content">
|
||||||
|
${!this._info
|
||||||
|
? html`<ha-circular-progress active></ha-circular-progress>`
|
||||||
|
: html`
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>URL</td>
|
||||||
|
<td>${this._info.url}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Active Dataset TLVs</td>
|
||||||
|
<td>${this._info.active_dataset_tlvs || "-"}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
`}
|
||||||
|
</div>
|
||||||
|
</ha-card>
|
||||||
|
</div>
|
||||||
|
</hass-subpage>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override firstUpdated(changedProps: PropertyValues) {
|
||||||
|
super.firstUpdated(changedProps);
|
||||||
|
|
||||||
|
threadGetInfo(this.hass).then((info) => {
|
||||||
|
this._info = info;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = [
|
||||||
|
haStyle,
|
||||||
|
css`
|
||||||
|
.content {
|
||||||
|
padding: 24px 0 32px;
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
direction: ltr;
|
||||||
|
}
|
||||||
|
ha-card:first-child {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"thread-config-panel": ThreadConfigPanel;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user