From 7c486ec969f2e25e679bc1c5af08eb55bddda255 Mon Sep 17 00:00:00 2001 From: Petar Petrov Date: Tue, 3 Dec 2024 14:56:17 +0200 Subject: [PATCH] ZWaveJS: abort S2 bootstrapping when inclusion is canceled (#23106) --- src/data/zwave_js.ts | 9 +++++++++ .../zwave_js/dialog-zwave_js-add-node.ts | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/data/zwave_js.ts b/src/data/zwave_js.ts index 265fb8bcb8f3..4bfe98acf5ff 100644 --- a/src/data/zwave_js.ts +++ b/src/data/zwave_js.ts @@ -962,3 +962,12 @@ export const fetchZwaveIntegrationSettings = ( hass.callWS({ type: "zwave_js/get_integration_settings", }); + +export const cancelSecureBootstrapS2 = ( + hass: HomeAssistant, + entry_id: string +): Promise => + hass.callWS({ + type: "zwave_js/cancel_secure_bootstrap_s2", + entry_id, + }); diff --git a/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-add-node.ts b/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-add-node.ts index 2b8435f0bb30..2e4a3ccc2500 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-add-node.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-add-node.ts @@ -22,6 +22,7 @@ import type { RequestedGrant, } from "../../../../../data/zwave_js"; import { + cancelSecureBootstrapS2, InclusionStrategy, MINIMUM_QR_STRING_LENGTH, provisionZwaveSmartStartNode, @@ -868,6 +869,16 @@ class DialogZWaveJSAddNode extends LitElement { } if (this._entryId) { stopZwaveInclusion(this.hass, this._entryId); + if ( + this._status && + [ + "waiting_for_device", + "validate_dsk_enter_pin", + "grant_security_classes", + ].includes(this._status) + ) { + cancelSecureBootstrapS2(this.hass, this._entryId); + } if (this._params?.onStop) { this._params.onStop(); }