Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
7452d848cThis file is pinned to the selected release. Download the original to open it in your design tool.
# ── HiveHub backend configuration ───────────────────────────────────────────
# Copy this file to `.env` (next to your docker-compose.yml) and fill in values.
# Generate strong random secrets with: openssl rand -hex 32
#
# API_KEY and POSTGRES_PASSWORD are REQUIRED — docker compose refuses to start
# without them (no insecure fallback defaults).
# Master/admin API key (X-API-Key header) for server-to-server tooling:
# firmware-release registration, command queueing, latest-measurements, time.
# Devices register their own per-device keys on first contact and don't need this.
API_KEY=change-this-to-a-long-random-string
# Service key used by the HivePal app backend (X-HivePal-Service-Key header).
HIVEPAL_SERVICE_API_KEY=change-this-to-another-long-random-string
# Shared secret (HS256) used to verify HivePal's per-user Bearer tokens.
# Must match HivePal's JWT_SECRET. Required for HivePal app endpoints.
HIVEPAL_JWT_SECRET=change-this-to-match-hivepal-jwt-secret
# PostgreSQL password. The compose file reuses it inside the default
# DATABASE_URL, so the API and the database can never drift apart.
POSTGRES_PASSWORD=change-this-database-password
# Public base URL used to build OTA firmware download links.
# Use HTTPS in production (behind your reverse proxy / Cloudflare).
# Without it, firmware download URLs are relative and device OTA will not work.
PUBLIC_BASE_URL=https://your-domain.example
# Timezone for logs and timestamps.
TZ=Europe/Berlin
# ── Built-in local dashboard (optional — OFF by default) ────────────────────
# When true, serves the static dashboard at /dashboard (e.g.
# http://<host>:31115/dashboard) backed by the /api/v1/local/* API. Access is
# protected by username + password login: the first visit runs a setup wizard
# that creates the initial admin account, and every data/control endpoint then
# requires a valid session (admin role for writes). It serves EVERY device on
# this server behind that one login, so keep it OFF on multi-tenant deployments.
ENABLE_LOCAL_DASHBOARD=false
# Signing secret for dashboard login sessions. Leave blank to auto-generate one
# (persisted in the database, so sessions survive restarts). Set it explicitly
# to pin the secret across replicas.
DASHBOARD_SESSION_SECRET=
# How long a dashboard login stays valid, in hours (default 168 = 7 days).
DASHBOARD_SESSION_TTL_HOURS=168
# Only send the session cookie over HTTPS (recommended; on by default). Keep it
# true whenever the dashboard is reached through the reverse proxy that
# terminates TLS. Set it to false only for plain-HTTP local testing — otherwise
# a secure cookie is never sent over http:// and login appears to fail.
DASHBOARD_COOKIE_SECURE=true
# ── Abuse / DoS protection (optional — sensible defaults shown) ──────────────
# Per-client-IP request rate limit. Set RATE_LIMIT_ENABLED=false to disable.
RATE_LIMIT_ENABLED=true
RATE_LIMIT_DEFAULT=120/minute
# Trust CF-Connecting-IP / X-Forwarded-For for the client IP. Off by default: it
# is only safe behind a trusted reverse proxy / Cloudflare that overwrites these
# headers, otherwise a client can spoof them to dodge the rate limiter. Set it
# to true once the API sits behind such a proxy so per-client limits key off the
# real client IP; leave it false if the port is ever exposed directly.
TRUST_PROXY_HEADERS=false
# Max size (bytes) of a normal JSON request body. 262144 = 256 KiB.
MAX_BODY_BYTES=262144
# Max size (bytes) of an uploaded firmware binary. 16777216 = 16 MiB.
MAX_FIRMWARE_BYTES=16777216
# ── MQTT bridge (optional — OFF by default) ─────────────────────────────────
# Mirror every incoming measurement to an MQTT broker (Home Assistant,
# Node-RED, openHAB, …) in addition to storing it in PostgreSQL. Purely
# additive and fail-soft: if the broker is down, ingestion is unaffected.
# Set MQTT_ENABLED=true to turn it on, then point MQTT_HOST at your broker.
MQTT_ENABLED=false
MQTT_HOST=localhost
MQTT_PORT=1883
MQTT_USERNAME=
MQTT_PASSWORD=
MQTT_TLS=false
MQTT_CLIENT_ID=hivescale-backend
# Root topic. Readings are published to <base>/<device_id>/state (retained).
MQTT_BASE_TOPIC=hivescale
MQTT_QOS=0
MQTT_RETAIN=true
# Home Assistant MQTT auto-discovery (publishes sensor configs automatically).
MQTT_HA_DISCOVERY=true
MQTT_HA_DISCOVERY_PREFIX=homeassistant
# Mark HA sensors "unavailable" if no update arrives within this many seconds.
# 0 disables it (sensible for devices on long deep-sleep reporting cycles).
MQTT_HA_EXPIRE_AFTER=0