mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Add support for Z-Wave DSK QR codes (#15542
Add support for zwave dsk qr codes
This commit is contained in:
parent
ca6ade4858
commit
5629346fc3
@ -440,7 +440,8 @@ export const subscribeAddZwaveNode = (
|
||||
inclusion_strategy: InclusionStrategy = InclusionStrategy.Default,
|
||||
qr_provisioning_information?: QRProvisioningInformation,
|
||||
qr_code_string?: string,
|
||||
planned_provisioning_entry?: PlannedProvisioningEntry
|
||||
planned_provisioning_entry?: PlannedProvisioningEntry,
|
||||
dsk?: string
|
||||
): Promise<UnsubscribeFunc> =>
|
||||
hass.connection.subscribeMessage((message) => callbackFunction(message), {
|
||||
type: "zwave_js/add_node",
|
||||
@ -449,6 +450,7 @@ export const subscribeAddZwaveNode = (
|
||||
qr_code_string,
|
||||
qr_provisioning_information,
|
||||
planned_provisioning_entry,
|
||||
dsk,
|
||||
});
|
||||
|
||||
export const stopZwaveInclusion = (hass: HomeAssistant, entry_id: string) =>
|
||||
@ -476,6 +478,17 @@ export const zwaveGrantSecurityClasses = (
|
||||
client_side_auth,
|
||||
});
|
||||
|
||||
export const zwaveTryParseDskFromQrCode = (
|
||||
hass: HomeAssistant,
|
||||
entry_id: string,
|
||||
qr_code_string: string
|
||||
) =>
|
||||
hass.callWS<string | null>({
|
||||
type: "zwave_js/try_parse_dsk_from_qr_code_string",
|
||||
entry_id,
|
||||
qr_code_string,
|
||||
});
|
||||
|
||||
export const zwaveValidateDskAndEnterPin = (
|
||||
hass: HomeAssistant,
|
||||
entry_id: string,
|
||||
|
@ -17,7 +17,6 @@ import type { HaTextField } from "../../../../../components/ha-textfield";
|
||||
import {
|
||||
InclusionStrategy,
|
||||
MINIMUM_QR_STRING_LENGTH,
|
||||
PlannedProvisioningEntry,
|
||||
provisionZwaveSmartStartNode,
|
||||
QRProvisioningInformation,
|
||||
RequestedGrant,
|
||||
@ -28,6 +27,7 @@ import {
|
||||
zwaveGrantSecurityClasses,
|
||||
zwaveParseQrCode,
|
||||
zwaveSupportsFeature,
|
||||
zwaveTryParseDskFromQrCode,
|
||||
zwaveValidateDskAndEnterPin,
|
||||
} from "../../../../../data/zwave_js";
|
||||
import { haStyle, haStyleDialog } from "../../../../../resources/styles";
|
||||
@ -515,6 +515,21 @@ class DialogZWaveJSAddNode extends LitElement {
|
||||
return;
|
||||
}
|
||||
this._qrProcessing = true;
|
||||
const dsk = await zwaveTryParseDskFromQrCode(
|
||||
this.hass,
|
||||
this._entryId!,
|
||||
qrCodeString
|
||||
);
|
||||
if (dsk) {
|
||||
this._status = "loading";
|
||||
// wait for QR scanner to be removed before resetting qr processing
|
||||
this.updateComplete.then(() => {
|
||||
this._qrProcessing = false;
|
||||
});
|
||||
this._inclusionStrategy = InclusionStrategy.Security_S2;
|
||||
this._startInclusion(undefined, dsk);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
qrCodeString.length < MINIMUM_QR_STRING_LENGTH ||
|
||||
!qrCodeString.startsWith("90")
|
||||
@ -623,15 +638,13 @@ class DialogZWaveJSAddNode extends LitElement {
|
||||
|
||||
private _startInclusion(
|
||||
qrProvisioningInformation?: QRProvisioningInformation,
|
||||
qrCodeString?: string,
|
||||
plannedProvisioningEntry?: PlannedProvisioningEntry
|
||||
dsk?: string
|
||||
): void {
|
||||
if (!this.hass) {
|
||||
return;
|
||||
}
|
||||
this._lowSecurity = false;
|
||||
const specificDevice =
|
||||
qrProvisioningInformation || qrCodeString || plannedProvisioningEntry;
|
||||
const specificDevice = qrProvisioningInformation || dsk;
|
||||
this._subscribed = subscribeAddZwaveNode(
|
||||
this.hass,
|
||||
this._entryId!,
|
||||
@ -697,8 +710,9 @@ class DialogZWaveJSAddNode extends LitElement {
|
||||
},
|
||||
this._inclusionStrategy,
|
||||
qrProvisioningInformation,
|
||||
qrCodeString,
|
||||
plannedProvisioningEntry
|
||||
undefined,
|
||||
undefined,
|
||||
dsk
|
||||
);
|
||||
this._addNodeTimeoutHandle = window.setTimeout(() => {
|
||||
this._unsubscribe();
|
||||
|
Loading…
x
Reference in New Issue
Block a user