mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +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,
|
inclusion_strategy: InclusionStrategy = InclusionStrategy.Default,
|
||||||
qr_provisioning_information?: QRProvisioningInformation,
|
qr_provisioning_information?: QRProvisioningInformation,
|
||||||
qr_code_string?: string,
|
qr_code_string?: string,
|
||||||
planned_provisioning_entry?: PlannedProvisioningEntry
|
planned_provisioning_entry?: PlannedProvisioningEntry,
|
||||||
|
dsk?: string
|
||||||
): Promise<UnsubscribeFunc> =>
|
): Promise<UnsubscribeFunc> =>
|
||||||
hass.connection.subscribeMessage((message) => callbackFunction(message), {
|
hass.connection.subscribeMessage((message) => callbackFunction(message), {
|
||||||
type: "zwave_js/add_node",
|
type: "zwave_js/add_node",
|
||||||
@ -449,6 +450,7 @@ export const subscribeAddZwaveNode = (
|
|||||||
qr_code_string,
|
qr_code_string,
|
||||||
qr_provisioning_information,
|
qr_provisioning_information,
|
||||||
planned_provisioning_entry,
|
planned_provisioning_entry,
|
||||||
|
dsk,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const stopZwaveInclusion = (hass: HomeAssistant, entry_id: string) =>
|
export const stopZwaveInclusion = (hass: HomeAssistant, entry_id: string) =>
|
||||||
@ -476,6 +478,17 @@ export const zwaveGrantSecurityClasses = (
|
|||||||
client_side_auth,
|
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 = (
|
export const zwaveValidateDskAndEnterPin = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry_id: string,
|
entry_id: string,
|
||||||
|
@ -17,7 +17,6 @@ import type { HaTextField } from "../../../../../components/ha-textfield";
|
|||||||
import {
|
import {
|
||||||
InclusionStrategy,
|
InclusionStrategy,
|
||||||
MINIMUM_QR_STRING_LENGTH,
|
MINIMUM_QR_STRING_LENGTH,
|
||||||
PlannedProvisioningEntry,
|
|
||||||
provisionZwaveSmartStartNode,
|
provisionZwaveSmartStartNode,
|
||||||
QRProvisioningInformation,
|
QRProvisioningInformation,
|
||||||
RequestedGrant,
|
RequestedGrant,
|
||||||
@ -28,6 +27,7 @@ import {
|
|||||||
zwaveGrantSecurityClasses,
|
zwaveGrantSecurityClasses,
|
||||||
zwaveParseQrCode,
|
zwaveParseQrCode,
|
||||||
zwaveSupportsFeature,
|
zwaveSupportsFeature,
|
||||||
|
zwaveTryParseDskFromQrCode,
|
||||||
zwaveValidateDskAndEnterPin,
|
zwaveValidateDskAndEnterPin,
|
||||||
} from "../../../../../data/zwave_js";
|
} from "../../../../../data/zwave_js";
|
||||||
import { haStyle, haStyleDialog } from "../../../../../resources/styles";
|
import { haStyle, haStyleDialog } from "../../../../../resources/styles";
|
||||||
@ -515,6 +515,21 @@ class DialogZWaveJSAddNode extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._qrProcessing = true;
|
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 (
|
if (
|
||||||
qrCodeString.length < MINIMUM_QR_STRING_LENGTH ||
|
qrCodeString.length < MINIMUM_QR_STRING_LENGTH ||
|
||||||
!qrCodeString.startsWith("90")
|
!qrCodeString.startsWith("90")
|
||||||
@ -623,15 +638,13 @@ class DialogZWaveJSAddNode extends LitElement {
|
|||||||
|
|
||||||
private _startInclusion(
|
private _startInclusion(
|
||||||
qrProvisioningInformation?: QRProvisioningInformation,
|
qrProvisioningInformation?: QRProvisioningInformation,
|
||||||
qrCodeString?: string,
|
dsk?: string
|
||||||
plannedProvisioningEntry?: PlannedProvisioningEntry
|
|
||||||
): void {
|
): void {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._lowSecurity = false;
|
this._lowSecurity = false;
|
||||||
const specificDevice =
|
const specificDevice = qrProvisioningInformation || dsk;
|
||||||
qrProvisioningInformation || qrCodeString || plannedProvisioningEntry;
|
|
||||||
this._subscribed = subscribeAddZwaveNode(
|
this._subscribed = subscribeAddZwaveNode(
|
||||||
this.hass,
|
this.hass,
|
||||||
this._entryId!,
|
this._entryId!,
|
||||||
@ -697,8 +710,9 @@ class DialogZWaveJSAddNode extends LitElement {
|
|||||||
},
|
},
|
||||||
this._inclusionStrategy,
|
this._inclusionStrategy,
|
||||||
qrProvisioningInformation,
|
qrProvisioningInformation,
|
||||||
qrCodeString,
|
undefined,
|
||||||
plannedProvisioningEntry
|
undefined,
|
||||||
|
dsk
|
||||||
);
|
);
|
||||||
this._addNodeTimeoutHandle = window.setTimeout(() => {
|
this._addNodeTimeoutHandle = window.setTimeout(() => {
|
||||||
this._unsubscribe();
|
this._unsubscribe();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user