Using Environment Variables to Change Notecard Configuration

Learn how to use environment variables, both built-in and custom, to change Notecard configuration remotely.
Read the full blog post at https://blues.dev/blog/changing-notecard-config-with-env-vars and continue the discussion here.
3 Likes

This is great! I didn’t know about the reserved environment variables for controlling sync behavior.

For example, if you use a Notecard’s hub.set request to set {"inbound":60}, and also have a _sync_inbound_mins environment variable on the device set to 120, your Notecard will use 120 as an inbound interval.

If you delete any of these variables your device will revert back to its default configuration.

On deleting the environment variable, does that mean the notecard would revert to what was set for inbound in the most recent hub.set request, (60 in the example), or the default value for the inbound parameter, which is 0?

Use -1 to reset the value back to its default of 0.
A value of 0 means that the Notecard will never sync inbound data unless explicitly told to do so (e.g. using hub.sync).

(from hub.set API docs)

Does that mean that setting -1 or 0 for the inbound property does the same thing, or perhaps that 0 isn’t a valid value to set?

Hey @devElert,

On deleting the environment variable, does that mean the notecard would revert to what was set for inbound in the most recent hub.set request, (60 in the example), or the default value for the inbound parameter, which is 0?

The environment variable doesn’t change your hub.set configuration.

When the Notecard sets its next synchronization interval it checks for the environment variable first. If no variable is present, it falls back to the hub.set request’s current inbound value. If inbound has never been set, it’ll use the default of 0.

Does that mean that setting -1 or 0 for the inbound property does the same thing, or perhaps that 0 isn’t a valid value to set?

They do the same thing. The -1 value is a standard way to reset numeric arguments throughout the Notecard’s API Essential Requests - Blues Developers.

TJ

2 Likes