ZWaveJS.NET icon indicating copy to clipboard operation
ZWaveJS.NET copied to clipboard

Fix up Smart Start

Open marcus-j-davies opened this issue 1 year ago • 3 comments

marcus-j-davies avatar Jun 26 '24 17:06 marcus-j-davies

@spudwebb

After some input from @AlCalzone, this PR reps the following.

ProvisionSmartStartNode now only accepts a SmartStartProvisioningEntry this is pretty much a Planned Provisioning Entry in the JS runtime

SmartStartProvisioningEntry can be created in 2 ways.

/* Your last PR - I added a default status */ 

public SmartStartProvisioningEntry(string dsk, SecurityClass[] securityClasses, Protocols protocol = Protocols.ZWave, ProvisioningEntryStatus status = ProvisioningEntryStatus.Active)
{
   this.dsk = dsk;
   this.securityClasses = securityClasses;
   this.requestedSecurityClasses = securityClasses;
   this.protocol = protocol;
   this.status = status;
   this.supportedProtocols = new Protocols[1] { protocol };
}
/* From a Parsed QR */

public SmartStartProvisioningEntry(QRProvisioningInformation ProvisioningInformation, Protocols protocol = Protocols.ZWave, ProvisioningEntryStatus status = ProvisioningEntryStatus.Active)
{
   if(!ProvisioningInformation.supportedProtocols.Contains(protocol))
   {
         throw new NotSupportedException("The provided protocol is not supported by this device.");
   }
           
   this.dsk = ProvisioningInformation.dsk;
   this.securityClasses = ProvisioningInformation.securityClasses;
   this.requestedSecurityClasses = ProvisioningInformation.securityClasses;
   this.supportedProtocols = ProvisioningInformation.supportedProtocols;
   this.protocol = protocol;
   this.status = status;
}

The securityClasses property of a SmartStartProvisioningEntry can be modified after creation, to allow Users to set what security classes they want to allow, after a QR code has been scanned for example

QRProvisioningInformation can be fetched by passing the QR Code Data to the Utils.ParseQRCodeString method

GetProvisioningEntries will return SmartStartProvisioningEntry[] with the additional nodeId if currently included

@AlCalzone, I believe this should fall more in line with what ProvisionSmartStartNode wants?

References: https://github.com/zwave-js/ZWaveJS.NET/blob/13a18366318e4c5a9f511d5e23c5b28e615a0a39/Visual%20Studio%20Projects/ZWaveJS.NET/ZWaveJS.NET/Structures.cs#L11

https://github.com/zwave-js/ZWaveJS.NET/blob/13a18366318e4c5a9f511d5e23c5b28e615a0a39/Visual%20Studio%20Projects/ZWaveJS.NET/ZWaveJS.NET/Structures.cs#L168

marcus-j-davies avatar Jun 26 '24 17:06 marcus-j-davies

I believe this should fall more in line with what ProvisionSmartStartNode wants?

The QR code can also contain additional info, like manufacturer and label. While it is not required to provision a node, it would still be good to copy all additional properties (that have a value) from QRProvisioningInformation to the PlannedProvisioningEntry, so they get persisted in the cache. Z-Wave JS UI for example shows them if they exist.

AlCalzone avatar Jun 27 '24 06:06 AlCalzone

Right!

I do that anyway, in NR - Thanks

marcus-j-davies avatar Jun 27 '24 16:06 marcus-j-davies