diff --git a/src/data/zwave_js.ts b/src/data/zwave_js.ts index 4940cd2d92..ab02e4acf8 100644 --- a/src/data/zwave_js.ts +++ b/src/data/zwave_js.ts @@ -126,6 +126,7 @@ export interface ZWaveJSNodeStatus { is_routing: boolean | null; zwave_plus_version: number | null; highest_security_class: SecurityClass | null; + is_controller_node: boolean; } export interface ZwaveJSNodeMetadata { diff --git a/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-actions-zwave_js.ts b/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-actions-zwave_js.ts index 2cd06cbea6..5d9a4205e6 100644 --- a/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-actions-zwave_js.ts +++ b/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-actions-zwave_js.ts @@ -10,8 +10,10 @@ import { import { customElement, property, state } from "lit/decorators"; import { DeviceRegistryEntry } from "../../../../../../data/device_registry"; import { + fetchZwaveNodeStatus, getZwaveJsIdentifiersFromDevice, ZWaveJSNodeIdentifiers, + ZWaveJSNodeStatus, } from "../../../../../../data/zwave_js"; import { haStyle } from "../../../../../../resources/styles"; import { HomeAssistant } from "../../../../../../types"; @@ -29,43 +31,67 @@ export class HaDeviceActionsZWaveJS extends LitElement { @state() private _nodeId?: number; + @state() private _node?: ZWaveJSNodeStatus; + protected updated(changedProperties: PropertyValues) { if (changedProperties.has("device")) { - this._entryId = this.device.config_entries[0]; - const identifiers: ZWaveJSNodeIdentifiers | undefined = getZwaveJsIdentifiersFromDevice(this.device); if (!identifiers) { return; } 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 { + if (!this._node) { + return html``; + } return html` - - - ${this.hass.localize( - "ui.panel.config.zwave_js.device_info.device_config" - )} - - - - ${this.hass.localize( - "ui.panel.config.zwave_js.device_info.reinterview_device" - )} - - - ${this.hass.localize("ui.panel.config.zwave_js.device_info.heal_node")} - - - ${this.hass.localize( - "ui.panel.config.zwave_js.device_info.remove_failed" - )} - + ${!this._node.is_controller_node + ? html` + + + ${this.hass.localize( + "ui.panel.config.zwave_js.device_info.device_config" + )} + + + + ${this.hass.localize( + "ui.panel.config.zwave_js.device_info.reinterview_device" + )} + + + ${this.hass.localize( + "ui.panel.config.zwave_js.device_info.heal_node" + )} + + + ${this.hass.localize( + "ui.panel.config.zwave_js.device_info.remove_failed" + )} + + ` + : ""} `; } diff --git a/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-info-zwave_js.ts b/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-info-zwave_js.ts index dc24356fff..32a732662f 100644 --- a/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-info-zwave_js.ts +++ b/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-info-zwave_js.ts @@ -103,52 +103,58 @@ export class HaDeviceInfoZWaveJS extends LitElement { ${this.hass.localize("ui.panel.config.zwave_js.common.node_id")}: ${this._node.node_id} -
- ${this.hass.localize( - "ui.panel.config.zwave_js.device_info.node_status" - )}: - ${this.hass.localize( - `ui.panel.config.zwave_js.node_status.${ - nodeStatus[this._node.status] - }` - )} -
-
- ${this.hass.localize( - "ui.panel.config.zwave_js.device_info.node_ready" - )}: - ${this._node.ready - ? this.hass.localize("ui.common.yes") - : this.hass.localize("ui.common.no")} -
-
- ${this.hass.localize( - "ui.panel.config.zwave_js.device_info.highest_security" - )}: - ${this._node.highest_security_class !== null - ? this.hass.localize( - `ui.panel.config.zwave_js.security_classes.${ - SecurityClass[this._node.highest_security_class] - }.title` - ) - : this._node.is_secure === false - ? this.hass.localize( - "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.zwave_plus" - )}: - ${this._node.zwave_plus_version - ? this.hass.localize( - "ui.panel.config.zwave_js.device_info.zwave_plus_version", - "version", - this._node.zwave_plus_version - ) - : this.hass.localize("ui.common.no")} -
+ ${!this._node.is_controller_node + ? html` +
+ ${this.hass.localize( + "ui.panel.config.zwave_js.device_info.node_status" + )}: + ${this.hass.localize( + `ui.panel.config.zwave_js.node_status.${ + nodeStatus[this._node.status] + }` + )} +
+
+ ${this.hass.localize( + "ui.panel.config.zwave_js.device_info.node_ready" + )}: + ${this._node.ready + ? this.hass.localize("ui.common.yes") + : this.hass.localize("ui.common.no")} +
+
+ ${this.hass.localize( + "ui.panel.config.zwave_js.device_info.highest_security" + )}: + ${this._node.highest_security_class !== null + ? this.hass.localize( + `ui.panel.config.zwave_js.security_classes.${ + SecurityClass[this._node.highest_security_class] + }.title` + ) + : this._node.is_secure === false + ? this.hass.localize( + "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.zwave_plus" + )}: + ${this._node.zwave_plus_version + ? this.hass.localize( + "ui.panel.config.zwave_js.device_info.zwave_plus_version", + "version", + this._node.zwave_plus_version + ) + : this.hass.localize("ui.common.no")} +
+ ` + : ""} `; }