How to call virtual parameters

As the document says
Just like a regular parameter, creating a virtual parameter does not automatically add it to the parameter list for a device. It needs to fetched (manually or via a preset) before you can see it in the data model.
How do I call virtual parameters in provisions, because presets seems to call provisions only.

Virtual parameters are user-defined parameters whose values are generated using a custom Javascript code. Virtual parameters behave just like regular parameters and appear in the data model under VirtualParameters. path. Virtual parameter names cannot contain a period ( . ).

// Read
declare("VirtualParameters.MyVirtualParam",{ value: Date.now()})

// Write
declare("VirtualParameters.MyVirtualParam", null , {value: new_value})

The values stored in a vparam are also primitive types (int, string, dateTime, etc).

I wrote a script
image
But the virtual parameters are not displayed on my UI.
There is a return value in the virtual parameter. How do I call it, it will come into effect when it is finished, or is it called in provisions? i have no idea.
image

Did you read the docs? More specifically the section regarding virtual parameters? If not, please read it first as it should make things more clear.

For your example, you named your virtual parameter ttt but you are using the name from my example in the provision: MyVirtualParam … it’s obvious this won’t work.

Also, in the test provision, if you want just to refresh the value you must omit the first line that basically overwrites it with 1 (which by the way should be a string to respect the way you defined it).

Thank you for your reply. I successfully added virtual parameters. I fell into a blind spot, thinking that virtual parameters are also scripts, so I don’t know how to call them.
In addition, do you know how to make ACS send setparametervalues command? I have tried the following commands, but none of them works.
image
image

1 Like

Why do you set value 1 if you actually want 2?
to correctly set a value you just assign it the wanted value:

declare("Phone.DN1_Number", {value: Date.now()}, {value: "2"});

the second parameter is important to refresh the current value first (genieacs will do the SetParameterValues RPC if the value requested is different from the one already set).

不幸的是,我没有收到setparametervalues命令。如果命令正确,则我猜CWMP中存在内部问题,因为HTTP仅收到不完整的消息。我尝试从源代码中对其进行修改。如果您有什么好的建议,请与我联系。非常感谢你!
图像
图像

You cut out the most important part from the conversation, the one where the device answers with the parameters it has under the “Phone.” path, that I suspect is empty or has a different name. In order for a value to be set it must be reported by the device.
PS: Please keep the language to english.

I have parameters when I don’t execute the script, but after I finish executing the above script, there are no related parameters.I don’t understand why the modification causes the loss of parameters.
image

image

because the provisioning script tries to refresh the parameters and the device probably says they are not there. Why don’t you paste also the values for these parameters? it’s hard to figure out exactly what happens if you filter information that is actually relevant.
Debug logs or full network capture should show exactly what happens but most probably it’s a device firmware bug. Try to obtain a newer firmware from your vendor and upgrade it.

I tested adding call parameters before and after the statement to modify the parameters, but it still didn’t work.
I thought it was a source problem, but I can use setparametervalues method in OpenACS test, which is a screenshot of OpenACS test.
image
The set statement of OpenACS is like this:
var parameters = new Array ();
parameters[0] = {name:‘Phone.DN0_UserName’, value: ‘5555’};
cpe.SetParameterValues (parameters, “commandKey”);
I didn’t find the official RPC call document in genieacs. I can only see some statements from the forum and try them. I want to ask what are the calling statements of several methods? I’ve tried to download it successfully.
image

I saw from mongodb that the data disappeared when executing setparametervalues.

db.devices.find()
{ “_id” : “DC293A-HSP00-2150081736BTD7007143”, “_deviceId” : { “_Manufacturer” : “HAAS”, “_OUI” : “DC293A”, “_ProductClass” : “HSP00”, “_SerialNumber” : “2150081736BTD7007143” }, “_lastBootstrap” : ISODate(“2021-04-10T08:12:45.703Z”), “_lastInform” : ISODate(“2021-04-10T08:12:45.703Z”), “_registered” : ISODate(“2021-03-23T06:46:29.527Z”), “Device” : { “DeviceInfo” : { “HardwareVersion” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “1.0.2” }, “Mac” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “dc:29:3a:00:f0:00” }, “SoftwareVersion” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : ““1.1.4”” }, “_object” : true }, “ManagementServer” : { “ConnectionRequestPassword” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “password” }, “ConnectionRequestURL” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “http://192.168.0.30:7547” }, “ConnectionRequestUsername” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “user” }, “ParameterKey” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “4545” }, “ProvisioningCode” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “1234” }, “SpecVersion” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “1” }, “_object” : true }, “WANDevice” : { “1” : { “WANConnectionDevice” : { “1” : { “WANIPConnection” : { “1” : { “LanIPAddress” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “192.168.0.30” }, “_object” : true }, “_object” : true }, “_object” : true }, “_object” : true }, “_object” : true }, “_object” : true }, “_object” : true }, “Phone” : { “_object” : true, “AutoProvision” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “1.0” }, “DN0_Number” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “koon001” }, “DN0_UserName” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “koon001” }, “DN1_Number” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “9999” }, “Number” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:12:45.704Z”), “_type” : “xsd:string”, “_value” : “600” } } }
db.devices.find()
{ “_id” : “DC293A-HSP00-2150081736BTD7007143”, “_deviceId” : { “_Manufacturer” : “HAAS”, “_OUI” : “DC293A”, “_ProductClass” : “HSP00”, “_SerialNumber” : “2150081736BTD7007143” }, “_lastBootstrap” : ISODate(“2021-04-10T08:17:59.734Z”), “_lastInform” : ISODate(“2021-04-10T08:17:59.734Z”), “_registered” : ISODate(“2021-03-23T06:46:29.527Z”), “Device” : { “DeviceInfo” : { “HardwareVersion” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:17:59.735Z”), “_type” : “xsd:string”, “_value” : ““1.1.4”” }, “Mac” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:17:59.735Z”), “_type” : “xsd:string”, “_value” : “dc:29:3a:00:f0:00” }, “SoftwareVersion” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:17:59.735Z”), “_type” : “xsd:string”, “_value” : ““1.1.4”” }, “_object” : true }, “ManagementServer” : { “ConnectionRequestPassword” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:17:59.735Z”), “_type” : “xsd:string”, “_value” : “password” }, “ConnectionRequestURL” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:17:59.735Z”), “_type” : “xsd:string”, “_value” : “http://192.168.0.30:7547” }, “ConnectionRequestUsername” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:17:59.735Z”), “_type” : “xsd:string”, “_value” : “user” }, “ParameterKey” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:17:59.735Z”), “_type” : “xsd:string”, “_value” : “4545” }, “ProvisioningCode” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:17:59.735Z”), “_type” : “xsd:string”, “_value” : “1234” }, “SpecVersion” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:17:59.735Z”), “_type” : “xsd:string”, “_value” : “1” }, “_object” : true }, “WANDevice” : { “1” : { “WANConnectionDevice” : { “1” : { “WANIPConnection” : { “1” : { “LanIPAddress” : { “_object” : false, “_timestamp” : ISODate(“2021-04-10T08:17:59.735Z”), “_type” : “xsd:string”, “_value” : “192.168.0.30” }, “_object” : true }, “_object” : true }, “_object” : true }, “_object” : true }, “_object” : true }, “_object” : true }, “_object” : true }, “Phone” : { “_object” : true, “_timestamp” : ISODate(“2021-04-10T08:17:59.734Z”) } }