setEnv()
setEnv(key, value)
Sets a device environment / configuration variable at runtime.
Adjusts device configuration from within a script. Known keys include:
| Key | Value | Effect |
|---|---|---|
"led" |
"green", "red", … |
Sets the front-panel status LED color. |
"log.clear" |
(none) | Clears the system log. |
"sys.utc_offset" |
number (hours) | Sets the clock's UTC offset, e.g. -8. |
"sys.meas_interval" |
seconds | Measurement interval. |
"sys.sync_interval" |
seconds | Server upload / sync interval. |
"enc.key" |
string | End-to-end encryption passphrase used for communication when encryption is activated. If not set, the device password is used. |
A practical use is adapting the measurement interval to communication outages
— see the Variable Measurement Interval example, which stretches the
interval as the measurement queue (__status().mqueue) fills.
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| key | string | yes | — | Environment variable name (see table above). |
| value | string | number | optional | — | New value. Some keys, like "log.clear", take no value. |
Example
setEnv("led", "green"); // status LED
setEnv("sys.utc_offset", -8); // Pacific time
setEnv("sys.meas_interval", 60); // measure every minute