Add zwave-js node alerts to device configuration page (#12173)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
Raman Gupta 2022-03-31 10:06:47 -04:00 committed by GitHub
parent 11696c566a
commit e6c580aadc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 14 deletions

View File

@ -167,12 +167,18 @@ export interface ZwaveJSNodeMetadata {
wakeup: string;
reset: string;
device_database_url: string;
comments: ZWaveJSNodeComment[];
}
export interface ZWaveJSNodeConfigParams {
[key: string]: ZWaveJSNodeConfigParam;
}
export interface ZWaveJSNodeComment {
level: "info" | "warning" | "error";
text: string;
}
export interface ZWaveJSNodeConfigParam {
property: number;
value: any;

View File

@ -19,6 +19,7 @@ import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import memoizeOne from "memoize-one";
import { debounce } from "../../../../../common/util/debounce";
import "../../../../../components/ha-alert";
import "../../../../../components/ha-card";
import "../../../../../components/ha-icon-next";
import "../../../../../components/ha-select";
@ -130,7 +131,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
></hass-error-screen>`;
}
if (!this._config) {
if (!this._config || !this._nodeMetadata) {
return html`<hass-loading-screen></hass-loading-screen>`;
}
@ -178,20 +179,27 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
</em>
</p>
</div>
<ha-card>
${this._config
? html`
${Object.entries(this._config).map(
([id, item]) => html` <ha-settings-row
class="config-item"
.configId=${id}
.narrow=${this.narrow}
>
${this._generateConfigBox(id, item)}
</ha-settings-row>`
${this._nodeMetadata.comments.length > 0
? html`
<div>
${this._nodeMetadata.comments.map(
(comment) => html`<ha-alert .alertType=${comment.level}>
${comment.text}
</ha-alert>`
)}
`
: ``}
</div>
`
: ``}
<ha-card>
${Object.entries(this._config).map(
([id, item]) => html` <ha-settings-row
class="config-item"
.configId=${id}
.narrow=${this.narrow}
>
${this._generateConfigBox(id, item)}
</ha-settings-row>`
)}
</ha-card>
</ha-config-section>
</hass-tabs-subpage>