Create instances in v1.2.3 issue

Hi,

I can’t create new WAN instances in v1.2.3 on bootstrap event with this old provision script used in v1.1:

const now = Date.now();

//Create WAN instances
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*", null, {path: 3});
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.*", {path: now}, {path: 1});
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.3.WANIPConnection.*", {path: now}, {path: 1});

This same script used in v1.1 works without problem but in this new version not. If create one previous preset (with higher weight) of type “refresh” and arguments “InternetGatewayDevice.WANDevice”, the script works but i don’t want to create 2 presets to do the same work.

It’s possible to do this (path refresh) from the same provision script without refreshing path in another preset?

I were tried to add a refresh path at the beggining of the provision script as follows but doesn’t works:
const now = Date.now();

//Refresh path
declare("InternetGatewayDevice.WANDevice", {path: now, value: now});

//Create instances
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*", null, {path: 3});
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.*", {path: now}, {path: 1});
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.3.WANIPConnection.*", {path: now}, {path: 1});

Thanks!

From an initial analysis of this, your declare params are incorrect, and you are telling Genie that you want 3 WAN devices, but then are specifying the instances. This is a very fragile way to do things, instance ids are never guaranteed.

For the specific way you are trying to create WAN ip instances, I’m not 100% sure of the syntax. But this is the syntax I use to create port mappings:

//Remove all existing instances, no changes will actually be committed to the device, unless the current state does not match the desired state
declare("Device.NAT.PortMapping.[]", null, {path: 0});

declare("Device.NAT.PortMapping.[PortMappingDescription:ssh,ExternalPort:1234,ExternalPortEndRange:1234,PortMappingEnabled:true,InternalClient:192.168.1.102,InternalPort:22]", {path: 1}, {path: 1});
declare("Device.NAT.PortMapping.[PortMappingDescription:https,ExternalPort:8080,ExternalPortEndRange:8080,PortMappingEnabled:true,InternalClient:192.168.1.102,InternalPort:80]", {path: 1}, {path: 1});