Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
5c2804327This file is pinned to the selected release. Download the original to open it in your design tool.
# ── HiveScale 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
# Admin/master API key (X-API-Key header) — used for firmware release uploads,
# admin command queuing, and other server-to-server operations.
# Individual devices now register their own per-device keys on first contact;
# this master key is no longer needed in device firmware for normal operation.
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
# JWT secret shared with HivePal — must match jwtConstants.secret in HivePal's
# auth.module.ts. Used to verify the Bearer tokens HivePal sends on behalf of
# its users. Generate with: openssl rand -hex 32
HIVEPAL_JWT_SECRET=change-this-to-match-hivepal-jwt-secret
# PostgreSQL password — must match POSTGRES_PASSWORD in docker-compose.yml.
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).
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, the server exposes a data + control API under /api/v1/local/* and
# serves the static dashboard at /dashboard. It covers EVERY device on this
# server, so access is protected by username + password login: the first visit
# runs a setup wizard that creates the initial admin account, after which every
# data/control endpoint requires a session (admins can change config/firmware/
# calibration and manage users; viewers are read-only). This makes it safe to
# expose to the internet, though serving it over HTTPS / behind a reverse proxy
# is still recommended. Leave it OFF on multi-tenant deployments (HivePal uses
# the authenticated /api/v1/app/* API instead).
ENABLE_LOCAL_DASHBOARD=false
# Signing secret for dashboard login sessions. Leave blank to auto-generate one
# and persist it in the database (sessions then survive restarts with no extra
# config); set it explicitly to share sessions across multiple replicas.
DASHBOARD_SESSION_SECRET=
# How long a dashboard login stays valid, in hours (default 168 = 7 days).
DASHBOARD_SESSION_TTL_HOURS=168
# Set true when serving the dashboard over HTTPS so the session cookie is only
# sent over TLS. Leave false for plain-HTTP LAN access.
DASHBOARD_COOKIE_SECURE=false
# ── 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 used as the
# rate-limit key. Keep true behind a reverse proxy you control (the documented
# setup, where the proxy overwrites these headers); set false when the API is
# exposed directly, otherwise clients can spoof the header to dodge the limiter.
TRUST_PROXY_HEADERS=true
# 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
# ── Insights history / alert lifecycle reconciliation (optional) ────────────
# A background thread periodically persists the lifecycle of sensor-based
# insight alerts into the insight_alerts table so HivePal can show a history.
# Set INSIGHTS_RECONCILE_ENABLED=false to disable the background thread (the
# summary endpoint still persists opportunistically when hit).
INSIGHTS_RECONCILE_ENABLED=true
# How often (seconds) the background reconciler sweeps all active devices.
INSIGHTS_RECONCILE_INTERVAL_SECONDS=900
# Lookback window (days) used for the persisted lifecycle. Kept fixed so
# history does not thrash as clients request different live windows.
INSIGHTS_HISTORY_LOOKBACK_DAYS=14
# ── Insight alert notifications (optional — OFF by default) ──────────────────
# When a new insight alert fires (or an existing one escalates), it can be
# pushed out over e-mail and/or Web Push. Both channels are independent and
# fail-soft: a broken relay never affects ingestion or the alert history.
# Only alerts at/above this severity are ever dispatched (info|watch|warning|
# critical). "warning" keeps the noisy lower tiers dashboard-only.
NOTIFY_MIN_SEVERITY=warning
# ── SMTP (e-mail channel) ────────────────────────────────────────────────────
# The recipient addresses are NOT set here — each dashboard account stores its
# own alert e-mail (Account → Alert email). These are the server-wide relay
# credentials only. Set SMTP_ENABLED=true and configure a relay to turn it on.
SMTP_ENABLED=false
SMTP_HOST=localhost
# 587 with STARTTLS is the usual submission port; 465 with implicit TLS also works.
SMTP_PORT=587
SMTP_USERNAME=
SMTP_PASSWORD=
# SMTP_STARTTLS upgrades a plain connection to TLS (port 587). Set SMTP_TLS=true
# instead for implicit TLS (SMTPS, port 465). Do not enable both.
SMTP_STARTTLS=true
SMTP_TLS=false
# From address (defaults to SMTP_USERNAME) and the display name shown to readers.
SMTP_FROM=
SMTP_FROM_NAME=HiveHub
SMTP_TIMEOUT_SECONDS=20
# ── Web Push (browser / installable PWA channel) ─────────────────────────────
# Generate a VAPID key pair once with `python gen_vapid.py` (prints the three
# values below), then paste them in and set WEB_PUSH_ENABLED=true. VAPID_SUBJECT
# must be a mailto: or https: URL identifying you to the push service. iOS only
# delivers Web Push to a PWA that has been added to the Home Screen (iOS 16.4+);
# Android/desktop Chrome/Firefox work from a normal tab.
WEB_PUSH_ENABLED=false
VAPID_PUBLIC_KEY=
VAPID_PRIVATE_KEY=
VAPID_SUBJECT=mailto:you@example.com
# ── 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.
MQTT_ENABLED=false
MQTT_HOST=localhost
MQTT_PORT=1883
# Broker credentials (leave blank for an anonymous broker).
MQTT_USERNAME=
MQTT_PASSWORD=
# Set MQTT_TLS=true to connect over TLS (port is usually 8883).
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 so a curated set
# of entities (weights, temps, humidity, battery, solar, signal, bee counts…)
# appears automatically. Set MQTT_HA_DISCOVERY=false to publish state only.
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