Skip to content

Commit

Permalink
Improve warnings for insecure zwavejs inclusion (#22456)
Browse files Browse the repository at this point in the history
* Improve warnings for insecure zwavejs inclusion

* is isNaN

Co-authored-by: Wendelin <[email protected]>

* use `nothing`

Co-authored-by: Wendelin <[email protected]>

---------

Co-authored-by: Wendelin <[email protected]>
  • Loading branch information
MindFreeze and wendevlin authored Oct 21, 2024
1 parent 206fbac commit 885a63d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class DialogZWaveJSAddNode extends LitElement {

@state() private _lowSecurity = false;

@state() private _lowSecurityReason?: number;

@state() private _supportsSmartStart?: boolean;

private _addNodeTimeoutHandle?: number;
Expand Down Expand Up @@ -406,6 +408,26 @@ class DialogZWaveJSAddNode extends LitElement {
)}</b
>
</p>
${this._lowSecurity
? html`<ha-alert
alert-type="warning"
title=${this.hass.localize(
"ui.panel.config.zwave_js.add_node.adding_insecurely"
)}
>
${this.hass.localize(
"ui.panel.config.zwave_js.add_node.added_insecurely_text"
)}
${typeof this._lowSecurityReason !==
"undefined"
? html`<p>
${this.hass.localize(
`ui.panel.config.zwave_js.add_node.low_security_reason.${this._lowSecurityReason}`
)}
</p>`
: ""}
</ha-alert>`
: ""}
${this._stages
? html` <div class="stages">
${this._stages.map(
Expand Down Expand Up @@ -489,12 +511,22 @@ class DialogZWaveJSAddNode extends LitElement {
${this._lowSecurity
? html`<ha-alert
alert-type="warning"
title="The device was added insecurely"
title=${this.hass.localize(
"ui.panel.config.zwave_js.add_node.added_insecurely"
)}
>
There was an error during secure
inclusion. You can try again by
excluding the device and adding it
again.
${this.hass.localize(
"ui.panel.config.zwave_js.add_node.added_insecurely_text"
)}
${typeof this
._lowSecurityReason !==
"undefined"
? html`<p>
${this.hass.localize(
`ui.panel.config.zwave_js.add_node.low_security_reason.${this._lowSecurityReason}`
)}
</p>`
: nothing}
</ha-alert>`
: ""}
<a
Expand Down Expand Up @@ -790,6 +822,7 @@ class DialogZWaveJSAddNode extends LitElement {
if (message.event === "node added") {
this._status = "interviewing";
this._lowSecurity = message.node.low_security;
this._lowSecurityReason = message.node.low_security_reason;
}

if (message.event === "interview completed") {
Expand Down Expand Up @@ -954,6 +987,10 @@ class DialogZWaveJSAddNode extends LitElement {
margin-inline-end: 20px;
margin-inline-start: initial;
}
.status {
flex: 1;
}
`,
];
}
Expand Down
16 changes: 15 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4966,7 +4966,21 @@
"view_device": "View Device",
"interview_started": "The device is being interviewed. This may take some time.",
"interview_failed": "The device interview failed. Additional information may be available in the logs.",
"waiting_for_device": "Communicating with the device. Please wait."
"waiting_for_device": "Communicating with the device. Please wait.",
"adding_insecurely": "The device is being added insecurely",
"added_insecurely": "The device was added insecurely",
"added_insecurely_text": "There was an error during secure inclusion. You can try again by excluding the device and adding it again.",
"low_security_reason": {
"0": "Security bootstrapping was canceled by the user.",
"1": "The required security keys were not configured in the driver.",
"2": "No Security S2 user callbacks (or provisioning info) were provided to grant security classes and/or validate the DSK.",
"3": "An expected message was not received within the corresponding timeout.",
"4": "There was no possible match in encryption parameters between the controller and the node.",
"5": "Security bootstrapping was canceled by the included node.",
"6": "The PIN was incorrect, so the included node could not decode the key exchange commands.",
"7": "There was a mismatch in security keys between the controller and the node.",
"8": "Unknown error occurred."
}
},
"provisioned": {
"dsk": "DSK",
Expand Down

0 comments on commit 885a63d

Please sign in to comment.