Omit Device info and actions for connected controller nodes (#11673)

This commit is contained in:
kpine 2022-02-14 08:06:03 -08:00 committed by GitHub
parent a321432175
commit 2ac0ad1d98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 103 additions and 70 deletions

View File

@ -126,6 +126,7 @@ export interface ZWaveJSNodeStatus {
is_routing: boolean | null; is_routing: boolean | null;
zwave_plus_version: number | null; zwave_plus_version: number | null;
highest_security_class: SecurityClass | null; highest_security_class: SecurityClass | null;
is_controller_node: boolean;
} }
export interface ZwaveJSNodeMetadata { export interface ZwaveJSNodeMetadata {

View File

@ -10,8 +10,10 @@ import {
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { DeviceRegistryEntry } from "../../../../../../data/device_registry"; import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
import { import {
fetchZwaveNodeStatus,
getZwaveJsIdentifiersFromDevice, getZwaveJsIdentifiersFromDevice,
ZWaveJSNodeIdentifiers, ZWaveJSNodeIdentifiers,
ZWaveJSNodeStatus,
} from "../../../../../../data/zwave_js"; } from "../../../../../../data/zwave_js";
import { haStyle } from "../../../../../../resources/styles"; import { haStyle } from "../../../../../../resources/styles";
import { HomeAssistant } from "../../../../../../types"; import { HomeAssistant } from "../../../../../../types";
@ -29,21 +31,41 @@ export class HaDeviceActionsZWaveJS extends LitElement {
@state() private _nodeId?: number; @state() private _nodeId?: number;
@state() private _node?: ZWaveJSNodeStatus;
protected updated(changedProperties: PropertyValues) { protected updated(changedProperties: PropertyValues) {
if (changedProperties.has("device")) { if (changedProperties.has("device")) {
this._entryId = this.device.config_entries[0];
const identifiers: ZWaveJSNodeIdentifiers | undefined = const identifiers: ZWaveJSNodeIdentifiers | undefined =
getZwaveJsIdentifiersFromDevice(this.device); getZwaveJsIdentifiersFromDevice(this.device);
if (!identifiers) { if (!identifiers) {
return; return;
} }
this._nodeId = identifiers.node_id; this._nodeId = identifiers.node_id;
this._entryId = this.device.config_entries[0];
this._fetchNodeDetails();
} }
} }
protected async _fetchNodeDetails() {
if (!this._nodeId || !this._entryId) {
return;
}
this._node = await fetchZwaveNodeStatus(
this.hass,
this._entryId,
this._nodeId
);
}
protected render(): TemplateResult { protected render(): TemplateResult {
if (!this._node) {
return html``;
}
return html` return html`
${!this._node.is_controller_node
? html`
<a <a
.href=${`/config/zwave_js/node_config/${this.device.id}?config_entry=${this._entryId}`} .href=${`/config/zwave_js/node_config/${this.device.id}?config_entry=${this._entryId}`}
> >
@ -59,13 +81,17 @@ export class HaDeviceActionsZWaveJS extends LitElement {
)} )}
</mwc-button> </mwc-button>
<mwc-button @click=${this._healNodeClicked}> <mwc-button @click=${this._healNodeClicked}>
${this.hass.localize("ui.panel.config.zwave_js.device_info.heal_node")} ${this.hass.localize(
"ui.panel.config.zwave_js.device_info.heal_node"
)}
</mwc-button> </mwc-button>
<mwc-button @click=${this._removeFailedNode}> <mwc-button @click=${this._removeFailedNode}>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.device_info.remove_failed" "ui.panel.config.zwave_js.device_info.remove_failed"
)} )}
</mwc-button> </mwc-button>
`
: ""}
`; `;
} }

View File

@ -103,6 +103,8 @@ export class HaDeviceInfoZWaveJS extends LitElement {
${this.hass.localize("ui.panel.config.zwave_js.common.node_id")}: ${this.hass.localize("ui.panel.config.zwave_js.common.node_id")}:
${this._node.node_id} ${this._node.node_id}
</div> </div>
${!this._node.is_controller_node
? html`
<div> <div>
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.device_info.node_status" "ui.panel.config.zwave_js.device_info.node_status"
@ -135,7 +137,9 @@ export class HaDeviceInfoZWaveJS extends LitElement {
? this.hass.localize( ? this.hass.localize(
"ui.panel.config.zwave_js.security_classes.none.title" "ui.panel.config.zwave_js.security_classes.none.title"
) )
: this.hass.localize("ui.panel.config.zwave_js.device_info.unknown")} : this.hass.localize(
"ui.panel.config.zwave_js.device_info.unknown"
)}
</div> </div>
<div> <div>
${this.hass.localize( ${this.hass.localize(
@ -149,6 +153,8 @@ export class HaDeviceInfoZWaveJS extends LitElement {
) )
: this.hass.localize("ui.common.no")} : this.hass.localize("ui.common.no")}
</div> </div>
`
: ""}
`; `;
} }