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; wakeup: string;
reset: string; reset: string;
device_database_url: string; device_database_url: string;
comments: ZWaveJSNodeComment[];
} }
export interface ZWaveJSNodeConfigParams { export interface ZWaveJSNodeConfigParams {
[key: string]: ZWaveJSNodeConfigParam; [key: string]: ZWaveJSNodeConfigParam;
} }
export interface ZWaveJSNodeComment {
level: "info" | "warning" | "error";
text: string;
}
export interface ZWaveJSNodeConfigParam { export interface ZWaveJSNodeConfigParam {
property: number; property: number;
value: any; value: any;

View File

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