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,9 +179,18 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
</em> </em>
</p> </p>
</div> </div>
<ha-card> ${this._nodeMetadata.comments.length > 0
${this._config
? html` ? 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( ${Object.entries(this._config).map(
([id, item]) => html` <ha-settings-row ([id, item]) => html` <ha-settings-row
class="config-item" class="config-item"
@ -190,8 +200,6 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
${this._generateConfigBox(id, item)} ${this._generateConfigBox(id, item)}
</ha-settings-row>` </ha-settings-row>`
)} )}
`
: ``}
</ha-card> </ha-card>
</ha-config-section> </ha-config-section>
</hass-tabs-subpage> </hass-tabs-subpage>