# Can I send setParametrValue with VirtualParameter?

**URL:** <https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466>\
**Category:** Uncategorized\
**Created:** [November 20, 2019, 11:27am UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466 "2019-11-20T11:27:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![supaflybro](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/supaflybro/32/123_2.png) [@supaflybro](https://forum.genieacs.com/u/supaflybro)\
**Post date:** [November 20, 2019, 11:27am UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466/1 "2019-11-20T11:27:16Z")

</div>

As far as I tested, line below is sending to CPE `setParametrValue` from provision, but sending `getParametrValue` from VirtualParameter.

> declare(“Device.WiFi.AccessPoint.1.Security.KeyPassphrase”, {value: Date.now()}, {value: ‘testpassword’});

Is it meant to be like this?

---

<div class="post-metadata">

**Author:** ![kyob](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/kyob/32/122_2.png) [@kyob](https://forum.genieacs.com/u/kyob)\
**Post date:** [November 20, 2019, 12:57pm UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466/2 "2019-11-20T12:57:36Z")

</div>

No sure I fully understand your question but you mean something like this:

```javascript
declare("VirtualParameters.*", {value: Date.now()});
let myNewVP = declare("VirtualParameters.myNewVP", {value: 1}).value[0];
declare("Device.WiFi.AccessPoint.1.Security.KeyPassphrase", {value: Date.now()}, {value: myNewVP});

```

---

<div class="post-metadata">

**Author:** ![supaflybro](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/supaflybro/32/123_2.png) [@supaflybro](https://forum.genieacs.com/u/supaflybro)\
**Post date:** [November 20, 2019, 2:44pm UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466/3 "2019-11-20T14:44:46Z")

</div>

No, I’m trying to replicate example from documentation, where you can [Create an editable virtual parameter for WPA passphrase](https://docs.genieacs.com/en/latest/virtual-parameters.html#create-an-editable-virtual-parameter-for-wpa-passphrase), but with args[] instead of VALUES.  
And I’m stuck on sending values to CPE. Started simplifying script and came up with script below sending `getParameterValue` instead `setParameterValue`:

```javascript
declare("Device.WiFi.AccessPoint.1.Security.KeyPassphrase", {value: Date.now()}, {value: 'testpass'});
return {writable: true, value: 'testpass'};

```

But the same `declare()` statement in a provision script is sending `setParameterValue` to CPE.

I’m trying to make unified parameters for wifi ssid and passphrase in tr-098 and tr-181 data models.

---

<div class="post-metadata">

**Author:** ![lavira](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@lavira](https://forum.genieacs.com/u/lavira)\
**Post date:** [November 21, 2019, 7:51am UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466/4 "2019-11-21T07:51:09Z")

</div>

AFAIK a declare statement does both!

`declare("Device.WiFi.AccessPoint.1.Security.KeyPassphrase", {value: Date.now()});`  
will do a getParameterValue to fetch the value from the CPE

`declare("Device.WiFi.AccessPoint.1.Security.KeyPassphrase", {value: Date.now()}, {value: 'testpass'});`  
will also do a getParameterValue followed by a setParameterValue **if the new value (‘testpass’) is different from the existing one**

I think you perceived it’s behaving differently because in the provision script you have a extra declare at the begining of the script just for refreshing the value and in this case the declare with value to set does just a setParameterValue RPC.

You should use _null_ for the second parameter to do just a SPV eventually:  
`declare(“Device.WiFi.AccessPoint.1.Security.KeyPassphrase”, null, {value: ‘testpass’});`

---

<div class="post-metadata">

**Author:** ![supaflybro](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/supaflybro/32/123_2.png) [@supaflybro](https://forum.genieacs.com/u/supaflybro)\
**Post date:** [November 22, 2019, 11:57am UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466/5 "2019-11-22T11:57:02Z")

</div>

I’m so confused rn.  
I’ve tried _null_ for a second parameter and it didn’t work.  
That’s what I get in CPE log with `null` in second parameter.

> easycwmpd: ACS initiated connection  
> easycwmpd: add event ‘6 CONNECTION REQUEST’  
> easycwmpd: start session  
> easycwmpd: configured acs url http://_my-ip_:7547/  
> easycwmpd: external script init  
> easycwmpd: external: execute inform parameter  
> easycwmpd: send Inform  
> easycwmpd: receive InformResponse from the ACS  
> easycwmpd: send empty message to the ACS  
> easycwmpd: receive empty message from the ACS  
> easycwmpd: external: execute apply service  
> easycwmpd: external script exit  
> easycwmpd: end session success

That’s what I get in CPE log with `{value: Date.now()}` in second parameter.

> easycwmpd: ACS initiated connection  
> easycwmpd: add event ‘6 CONNECTION REQUEST’  
> easycwmpd: start session  
> easycwmpd: configured acs url http://_my-ip_:7547/  
> easycwmpd: external script init  
> easycwmpd: external: execute inform parameter  
> easycwmpd: send Inform  
> easycwmpd: receive InformResponse from the ACS  
> easycwmpd: send empty message to the ACS  
> easycwmpd: received GetParameterValues method from the ACS  
> easycwmpd: external: execute get value Device.WiFi.AccessPoint.1.Security.KeyPassphrase  
> easycwmpd: send GetParameterValuesResponse to the ACS  
> easycwmpd: receive empty message from the ACS  
> easycwmpd: external: execute apply service  
> easycwmpd: external script exit  
> easycwmpd: end session success

That’s what i get in CPE log when changing `Device.WiFi.AccessPoint.1.Security.KeyPassphrase` normal way from giu.

> easycwmpd: ACS initiated connection  
> easycwmpd: add event ‘6 CONNECTION REQUEST’  
> easycwmpd: start session  
> easycwmpd: configured acs url http://_my-ip_:7547/  
> easycwmpd: external script init  
> easycwmpd: external: execute inform parameter  
> easycwmpd: send Inform  
> easycwmpd: receive InformResponse from the ACS  
> easycwmpd: send empty message to the ACS  
> easycwmpd: received SetParameterValues method from the ACS  
> easycwmpd: external: execute set value Device.WiFi.AccessPoint.1.Security.KeyPassphrase testpass  
> easycwmpd: external: execute apply value  
> easycwmpd: send SetParameterValuesResponse to the ACS  
> easycwmpd: receive empty message from the ACS  
> easycwmpd: external: execute apply service  
> easycwmpd: external script exit  
> easycwmpd: end session success

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [November 23, 2019, 10:05pm UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466/6 "2019-11-23T22:05:14Z")

</div>

Are you using v1.2 or v1.1?

---

<div class="post-metadata">

**Author:** ![supaflybro](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/supaflybro/32/123_2.png) [@supaflybro](https://forum.genieacs.com/u/supaflybro)\
**Post date:** [November 24, 2019, 11:09am UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466/7 "2019-11-24T11:09:05Z")

</div>

I’m using latest github release v1.2

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [November 24, 2019, 9:11pm UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466/8 "2019-11-24T21:11:03Z")

</div>

So that was a bug and I have just fixed it. Try the latest master branch.

---

<div class="post-metadata">

**Author:** ![supaflybro](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/supaflybro/32/123_2.png) [@supaflybro](https://forum.genieacs.com/u/supaflybro)\
**Post date:** [November 24, 2019, 11:06pm UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466/9 "2019-11-24T23:06:19Z")

</div>

Thank you very much!)

---

<div class="post-metadata">

**Author:** ![supaflybro](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/supaflybro/32/123_2.png) [@supaflybro](https://forum.genieacs.com/u/supaflybro)\
**Post date:** [November 26, 2019, 9:27am UTC](https://forum.genieacs.com/t/can-i-send-setparametrvalue-with-virtualparameter/466/10 "2019-11-26T09:27:15Z")

</div>

It’s working well, thanl you. When will it be available in npm?
