env_example.json
What is the purpose of env_example.json?
env_example.json is a contract between the Unit Developer and Pepeunit:
- 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.
- Pepeunit guarantees that Users will be able to set the variables specified by the Unit Developer.
- 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:
| Variable | Generated value in env.json | Purpose |
|---|---|---|
PU_DOMAIN | PU_DOMAIN from Backend ENV | Domain name or IP address of the Pepeunit instance. |
PU_HTTP_TYPE | PU_SECURE from Backend ENV | Connection type https/http to the Backend domain or IP, in the https/http format. |
PU_APP_PREFIX | PU_APP_PREFIX from Backend ENV | Backend prefix. |
PU_API_ACTUAL_PREFIX | PU_API_V1_PREFIX from Backend ENV | Prefix of the current API version of the Backend. Always points to the latest API version. |
PU_MQTT_HOST | PU_MQTT_HOST from Backend ENV | Domain or IP address of the EMQX instance. |
PU_MQTT_PORT | PU_MQTT_PORT from Backend ENV | Port for communication with EMQX, 1883 by default. |
PU_MQTT_PING_INTERVAL | 30 | MQTT ping interval in seconds (30 seconds for everyone). |
PU_AUTH_TOKEN | jwt token | Permanent 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_KEY | 32‑byte key in base64 format | Unique for each Unit. Convenient for signing or generating JWTs. Set automatically by the Backend. |
PU_ENCRYPT_KEY | 32‑byte key in base64 format | Unique for each Unit. Convenient for aes-gcm-256 encryption. Set automatically by the Backend. |
PU_STATE_SEND_INTERVAL | PU_STATE_SEND_INTERVAL from Backend ENV | Interval for sending state to the standard state topic. |
PU_MIN_LOG_LEVEL | Debug | Minimum 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_LENGTH | 64 | Maximum number of lines in log.json; old lines are removed from the beginning of the file. |
PU_COMMIT_VERSION | Commit hash | Shows 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.