Skip to content

env_example.json

What is the purpose of env_example.json?

env_example.json is a contract between the Unit Developer and Pepeunit:

  1. The Unit Developer guarantees that they will implement in the Unit logic all or some of the standard Pepeunit variables required for integration with Pepeunit.
  2. Pepeunit guarantees that Users will be able to set the variables specified by the Unit Developer.
  3. Pepeunit guarantees that it will automatically populate the standard variables defined in this file when the User first saves the env.

Structure

json
{   
    "WIFI_SSID": "ssid",
    "WIFI_PASS": "password",
    "PWM_FAN_PIN": 0,
    "DS18B20_PIN_NUM": 4,
    "REGULATOR_OPERATING_RANGE": 1000,
    "PUBLISH_SEND_INTERVAL": 1,
    "TEMP_MIN": 30,
    "TEMP_MAX": 60,
    "DUTY_MIN": 8192,
    "DUTY_MAX": 65535,
    "PU_DOMAIN": "unit.example.com",
    "PU_HTTP_TYPE": "https",
    "PU_APP_PREFIX": "/pepeunit",
    "PU_API_ACTUAL_PREFIX": "/api/v1",
    "PU_MQTT_HOST": "emqx.example.com",
    "PU_MQTT_PORT": 1883,
    "PU_MQTT_PING_INTERVAL": 30,
    "PU_AUTH_TOKEN": "jwt_token",
    "PU_SECRET_KEY": "32_bit_secret_key",
    "PU_ENCRYPT_KEY": "32_bit_encrypt_key",
    "PU_STATE_SEND_INTERVAL": 300,
    "PU_MIN_LOG_LEVEL": "Debug",
    "PU_MAX_LOG_LENGTH": 64
}

You can divide the variables into two categories: standard variables and developer environment variables.

Standard Pepeunit variables

Pepeunit reserves the following set of environment variables for a Unit:

VariableGenerated value in env.jsonPurpose
PU_DOMAINPU_DOMAIN from Backend ENVDomain name or IP address of the Pepeunit instance.
PU_HTTP_TYPEPU_SECURE from Backend ENVConnection type https/http to the Backend domain or IP, in the https/http format.
PU_APP_PREFIXPU_APP_PREFIX from Backend ENVBackend prefix.
PU_API_ACTUAL_PREFIXPU_API_V1_PREFIX from Backend ENVPrefix of the current API version of the Backend. Always points to the latest API version.
PU_MQTT_HOSTPU_MQTT_HOST from Backend ENVDomain or IP address of the EMQX instance.
PU_MQTT_PORTPU_MQTT_PORT from Backend ENVPort for communication with EMQX, 1883 by default.
PU_MQTT_PING_INTERVAL30MQTT ping interval in seconds (30 seconds for everyone).
PU_AUTH_TOKENjwt tokenPermanent access token of the Unit to the Pepeunit instance. This token is used to authorize subscriptions and publications in EMQX topics and is set automatically by the Backend.
PU_SECRET_KEY32‑byte key in base64 formatUnique for each Unit. Convenient for signing or generating JWTs. Set automatically by the Backend.
PU_ENCRYPT_KEY32‑byte key in base64 formatUnique for each Unit. Convenient for aes-gcm-256 encryption. Set automatically by the Backend.
PU_STATE_SEND_INTERVALPU_STATE_SEND_INTERVAL from Backend ENVInterval for sending state to the standard state topic.
PU_MIN_LOG_LEVELDebugMinimum log level that will be sent over MQTT and stored in the log.json file. For example, if you set it to Warning, then Debug and Info messages will not be sent.
PU_MAX_LOG_LENGTH64Maximum number of lines in log.json; old lines are removed from the beginning of the file.
PU_COMMIT_VERSIONCommit hashShows the current target version of the Unit. It has special behavior: it cannot be changed manually in the env.json editing UI; any attempt to change it will be ignored.

Unit Developer environment variables

The Unit Developer can create any environment variables whose names differ from the standard ones. The values defined in these variables will be shown as default values in the User interface.

DANGER

Since in the end it is the User who will fill in the variables manually, you must always provide pepeunit.toml and readme.md so that the User can understand what each variable controls.

DANGER

env.json is filled by the User based on the ENV generation mechanism.