A simple Alpstuga air quality Prometheus exporter for my personal use.
Stack:
- Bun - JavaScript runtime
- Hono - Web framework
- Dirigera - Unofficial IKEA Dirigera hub API client
- Pino - Structured logging library
Tip
Use bunx dirigera authenticate --no-reject-unauthorized to authenticate with the Dirigera hub and get a token.
Configuration is done through environment variables.
| Variable | Description | Default |
|---|---|---|
ACCESS_TOKEN |
Access token for the Dirigera hub | Required |
GATEWAY_IP |
IP address of the Dirigera hub | Auto discovery via mDNS |
ACCEPT_UNAUTHORIZED |
Accept unauthorized certificates | false |
LOGGING_LEVEL |
Logging level (trace, debug, info, warn, error, fatal) | error |
PORT |
Port to listen on | 9001 |
COLLECT_DEFAULT |
Collect default metrics | false |
With bun:
# Install dependencies
bun i
# Create a .env file with the required variables
touch .env
# With json structured logging
bun start
# or
bun src/index.ts
# With pretty logging
bun devWith docker:
docker build -t alpstuga-exporter .
docker run -p 9001:9001 --env-file .env alpstuga-exporterYou can find a premade dashboard here.
You can test the exporter locally through the compose stack:
# Up
docker compose up -d --build
# Reset
docker compose down && docker volume prune -a