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,43 +31,67 @@ 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`
<a ${!this._node.is_controller_node
.href=${`/config/zwave_js/node_config/${this.device.id}?config_entry=${this._entryId}`} ? html`
> <a
<mwc-button> .href=${`/config/zwave_js/node_config/${this.device.id}?config_entry=${this._entryId}`}
${this.hass.localize( >
"ui.panel.config.zwave_js.device_info.device_config" <mwc-button>
)} ${this.hass.localize(
</mwc-button> "ui.panel.config.zwave_js.device_info.device_config"
</a> )}
<mwc-button @click=${this._reinterviewClicked}> </mwc-button>
${this.hass.localize( </a>
"ui.panel.config.zwave_js.device_info.reinterview_device" <mwc-button @click=${this._reinterviewClicked}>
)} ${this.hass.localize(
</mwc-button> "ui.panel.config.zwave_js.device_info.reinterview_device"
<mwc-button @click=${this._healNodeClicked}> )}
${this.hass.localize("ui.panel.config.zwave_js.device_info.heal_node")} </mwc-button>
</mwc-button> <mwc-button @click=${this._healNodeClicked}>
<mwc-button @click=${this._removeFailedNode}> ${this.hass.localize(
${this.hass.localize( "ui.panel.config.zwave_js.device_info.heal_node"
"ui.panel.config.zwave_js.device_info.remove_failed" )}
)} </mwc-button>
</mwc-button> <mwc-button @click=${this._removeFailedNode}>
${this.hass.localize(
"ui.panel.config.zwave_js.device_info.remove_failed"
)}
</mwc-button>
`
: ""}
`; `;
} }

View File

@ -103,52 +103,58 @@ 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>
<div> ${!this._node.is_controller_node
${this.hass.localize( ? html`
"ui.panel.config.zwave_js.device_info.node_status" <div>
)}: ${this.hass.localize(
${this.hass.localize( "ui.panel.config.zwave_js.device_info.node_status"
`ui.panel.config.zwave_js.node_status.${ )}:
nodeStatus[this._node.status] ${this.hass.localize(
}` `ui.panel.config.zwave_js.node_status.${
)} nodeStatus[this._node.status]
</div> }`
<div> )}
${this.hass.localize( </div>
"ui.panel.config.zwave_js.device_info.node_ready" <div>
)}: ${this.hass.localize(
${this._node.ready "ui.panel.config.zwave_js.device_info.node_ready"
? this.hass.localize("ui.common.yes") )}:
: this.hass.localize("ui.common.no")} ${this._node.ready
</div> ? this.hass.localize("ui.common.yes")
<div> : this.hass.localize("ui.common.no")}
${this.hass.localize( </div>
"ui.panel.config.zwave_js.device_info.highest_security" <div>
)}: ${this.hass.localize(
${this._node.highest_security_class !== null "ui.panel.config.zwave_js.device_info.highest_security"
? this.hass.localize( )}:
`ui.panel.config.zwave_js.security_classes.${ ${this._node.highest_security_class !== null
SecurityClass[this._node.highest_security_class] ? this.hass.localize(
}.title` `ui.panel.config.zwave_js.security_classes.${
) SecurityClass[this._node.highest_security_class]
: this._node.is_secure === false }.title`
? this.hass.localize( )
"ui.panel.config.zwave_js.security_classes.none.title" : this._node.is_secure === false
) ? this.hass.localize(
: this.hass.localize("ui.panel.config.zwave_js.device_info.unknown")} "ui.panel.config.zwave_js.security_classes.none.title"
</div> )
<div> : this.hass.localize(
${this.hass.localize( "ui.panel.config.zwave_js.device_info.unknown"
"ui.panel.config.zwave_js.device_info.zwave_plus" )}
)}: </div>
${this._node.zwave_plus_version <div>
? this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.device_info.zwave_plus_version", "ui.panel.config.zwave_js.device_info.zwave_plus"
"version", )}:
this._node.zwave_plus_version ${this._node.zwave_plus_version
) ? this.hass.localize(
: this.hass.localize("ui.common.no")} "ui.panel.config.zwave_js.device_info.zwave_plus_version",
</div> "version",
this._node.zwave_plus_version
)
: this.hass.localize("ui.common.no")}
</div>
`
: ""}
`; `;
} }