# Setting a notecard serial number "sn" remotely

**URL:** <https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174>\
**Category:** Notecard API\
**Created:** [March 18, 2021, 9:27pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174 "2021-03-18T21:27:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/pat/32/143_2.png) [@Pat](https://discuss.blues.com/u/Pat)\
**Post date:** [March 18, 2021, 9:27pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174/1 "2021-03-18T21:27:44Z")

</div>

Can a notecard’s “sn” be set remotely by [notehub.io](https://notehub.io) dashboard or [notehub.io](https://notehub.io) API?

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [March 18, 2021, 11:56pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174/2 "2021-03-18T23:56:56Z")

</div>

Hi @Pat,

Yes, in fact you can use [environment variables](https://dev.blues.io/build/notecard-guides/understanding-environment-variables/) to set the “serial number” for a device.

Use `_sn` to override any previously-entered serial number.  
Use `_sn_default` to set it, but _not_ override the value if set already on the Notecard.

To access environment variables, look at the “Environment” tab when browsing device details:

 ![Screen Shot 2021-03-18 at 6.50.25 PM](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/29e15481c2e6ea204c6f5b83123fc16d80e31314.png)

---

<div class="post-metadata">

**Author:** ![Pat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/pat/32/143_2.png) [@Pat](https://discuss.blues.com/u/Pat)\
**Post date:** [March 19, 2021, 1:40pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174/3 "2021-03-19T13:40:43Z")

</div>

Hello @RobLauer ,

Thank you for the information.  
But, I’m still not having success in changing “sn” remotely . The “sn” below is still not changed. I’ve used env.default on the device to set “sn” and “\_sn”  
On [notehub.io](https://notehub.io) it says: This notecard has not used the “env.default” request to set environment variable defaults

The JSON below is from a button press, after the Notecard is set to: {“req”:“card.aux”,“mode”:“monitor”}

A low on Aux1 does send a button response.

{  
“event”: “928b2413-4f8e-4c82-bc5a-dda0a4885a82”,  
“session”: “ed6160b9-1ca1-43f0-a0dc-2819c9118e5e”,  
“device”: “dev:86462204049XXXX”,  
**"sn": “15553331212”,** \< doesn’t change with \_sn environment variable change  
“product”: “product:ws.hometech.pj:XXXXXX”,  
“received”: 1616160167.127255,  
“routed”: 1616160167,  
“req”: “note.add”,  
“when”: 1616160167,  
“file”: “\_button.qo”,  
“body”: {  
“button”: 1  
},

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [March 19, 2021, 2:41pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174/4 "2021-03-19T14:41:50Z")

</div>

Interesting. I just tried setting `_sn` env variable and on the “Device Info” tab my test sn shows up immediately next to “Serial Number”.

Can you clarify where on [Notehub.io](http://Notehub.io) you see that message? Definitely want to diagnose this issue for you.

---

<div class="post-metadata">

**Author:** ![Pat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/pat/32/143_2.png) [@Pat](https://discuss.blues.com/u/Pat)\
**Post date:** [March 19, 2021, 4:05pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174/5 "2021-03-19T16:05:09Z")

</div>

Hello @RobLauer

Screenshots:  
Under Device Details:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/925f191fdb3ed168df86a5bf5ee6902d73cd5705.png)

Under Environment… It now shows up but still not sent in JSON by Button Press

 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/792f6eff1f2adb0002e497219492c8f9f3c86a8f.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/5e54eae5bac0e84f8390ba04565d0b0ace8e5baa.png)

I had previously set SN to 15553331212 by USB to notecard.  
Still receive:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/cb4459328c4e2f95a85174bface6a2ee3f38b713.png)

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [March 19, 2021, 6:36pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174/6 "2021-03-19T18:36:37Z")

</div>

Still looking into this! I can replicate at least one part of the problem here (the Notehub UI is not updating with the `_sn` override value).

However, if I perform a `{"req":"env.get","name":"_sn"}` on the device I _do_ see the updated sn.

Am I correct in assuming you are not seeing the updated sn with an `env.get` request?

---

<div class="post-metadata">

**Author:** ![Pat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/pat/32/143_2.png) [@Pat](https://discuss.blues.com/u/Pat)\
**Post date:** [March 19, 2021, 7:11pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174/7 "2021-03-19T19:11:48Z")

</div>

@RobLauer

It took a manual reboot to refresh “sn” in the JSON package sent from Notecard from a Button Press.

After rebooting:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/05a243dcbdd04174bb381d37f5e93236bffb30a6.png)

After Button Press:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/48d4753fb97064c599ee129dc7fe2001ae408cb5.png)

Not returning Device environmental variable “\_sn”

 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/52c710164352ceea49c18307b688717b791b6f97.png)

Thanks for your replies.

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [March 21, 2021, 4:16pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174/8 "2021-03-21T16:16:56Z")

</div>

Hi @Pat,

I just wanted to follow up on this as there was a bug in Notehub (since fixed) that wasn’t properly displaying the updated serial number. Can you verify it’s working correctly for you?

Note that the device itself won’t reflect the updated sn until it syncs with Notehub.

Thanks,  
Rob

---

<div class="post-metadata">

**Author:** ![Pat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/pat/32/143_2.png) [@Pat](https://discuss.blues.com/u/Pat)\
**Post date:** [March 21, 2021, 9:06pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174/9 "2021-03-21T21:06:24Z")

</div>

Hello @RobLauer ,

Thanks for continuing to follow up on this. I updated the env variable to “apple”  
It displays in the device Info screen as shown below:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/9ebc712bd070da5ccf0ef43db6bf8324fe49c6e9.png)  
I did a manual hub.sync.

![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/f42fd7024e1bba70c78d7cc83d0134d018d9658d.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/8a867f68d1cdaae13369e699ee0be9147ade1e39.png)

A button press still reflects previous sn:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/25a774bbb89b6d49ca511b990b6d67e942e0cce9.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/ad9e667b0c0e49e7a43b072ae5b664e9f5201b03.png)

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [March 22, 2021, 2:08pm UTC](https://discuss.blues.com/t/setting-a-notecard-serial-number-sn-remotely/174/10 "2021-03-22T14:08:51Z")

</div>

Hi @Pat,

Thanks for your patience on this! I have a couple other thoughts:

Is there any chance you set the sn with `env.set`? For example: `{"req":"env.set","name":"_sn","text":"mysn"}`

If you did, you should know that these local environment variables **cannot** be overridden by a Notehub variable of any scope by design. This would explain why Notehub isn’t overriding it locally.

The proper way to set sn locally is with [hub.set](https://dev.blues.io/reference/complete-api-reference/hub-requests/#hub-set).

Otherwise, next step would be for us to take a look at your device’s `_env.dbs` file. If you use the web REPL on [dev.blues.io](https://dev.blues.io) you can access that with: `dump _env.dbs`. You can DM me with the file.

Thanks,  
Rob
