Setting a notecard serial number "sn" remotely

Can a notecard’s “sn” be set remotely by notehub.io dashboard or notehub.io API?

Hi @Pat,

Yes, in fact you can use 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:

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 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.

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 you see that message? Definitely want to diagnose this issue for you.

Hello @RobLauer

Screenshots:
Under Device Details:
image

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

I had previously set SN to 15553331212 by USB to notecard.
Still receive:
image

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?

@RobLauer

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

After rebooting:
image

After Button Press:
image

Not returning Device environmental variable “_sn”

Thanks for your replies.

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

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
I did a manual hub.sync.

image
image

A button press still reflects previous sn:
image

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.

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 you can access that with: dump _env.dbs. You can DM me with the file.

Thanks,
Rob

2 Likes