A lightweight Docker container that bridges apcupsd UPS monitoring with Uptime Kuma notifications and provides HTTP API endpoints for UPS status monitoring.
- Real-time UPS monitoring: Connects to remote apcupsd daemon via NIS protocol
- Event-driven notifications: Alerts on power loss, battery low, high load, etc.
- HTTP API endpoints: REST API for UPS status monitoring and health checks
- Multiple operation modes: Uptime Kuma notifications, HTTP-only, or combined mode
- Smart thresholds: Automatically detects apcupsd configuration for battery and time limits
- Comprehensive monitoring: Tracks 30+ UPS metrics including battery charge, load percentage, and time remaining
- Docker deployment: Easy deployment as a containerized service
- Robust error handling: Graceful handling of network issues and UPS disconnections
-
Download the compose file:
curl -O https://raw.githubusercontent.com/hedger/apcupsd-uptime-kuma-bridge/main/docker-compose.yml curl -O https://raw.githubusercontent.com/hedger/apcupsd-uptime-kuma-bridge/main/.env.example
-
Configure environment:
cp .env.example .env # Edit .env with your settings -
Deploy:
docker compose up -d
docker run -d \
--name apcupsd-uptime-kuma-bridge \
--restart unless-stopped \
-p 8080:8080 \
-e APCUPSD_HOST=192.168.1.100 \
-e UPTIME_KUMA_PUSH_URL="https://your-kuma.domain.com/api/push/XXXXXXXX" \
ghcr.io/hedger/apcupsd-uptime-kuma-bridge:latest| Variable | Default | Description |
|---|---|---|
APCUPSD_HOST |
192.168.1.100 |
IP address of apcupsd server |
APCUPSD_PORT |
3551 |
Port of apcupsd daemon |
UPTIME_KUMA_PUSH_URL |
optional | Uptime Kuma push notification URL |
HTTP_ENABLED |
true |
Enable HTTP API server |
HTTP_PORT |
8080 |
Port for HTTP API endpoints |
HEARTBEAT_INTERVAL |
60 |
Heartbeat interval in seconds |
POLL_INTERVAL |
10 |
UPS status polling interval in seconds |
TZ |
UTC |
Timezone for logging |
🔧 Operational Modes: You can run the monitor in three modes:
- Uptime Kuma + HTTP (default): Both push notifications and HTTP API endpoints
- Uptime Kuma only: Set
HTTP_ENABLED=falseto disable HTTP API- HTTP only: Leave
UPTIME_KUMA_PUSH_URLempty to run without push notifications
💡 Pro Tip: All status messages are now fully customizable! See CONFIG.md for complete documentation of message customization options including emoji support and multilingual messages.
- Open your Uptime Kuma dashboard
- Go to Settings > Monitors
- Click Add New Monitor
- Select Push as monitor type
- Copy the generated push URL from the setup instructions
The monitor will send notifications for:
- UPS switches to battery power
- Power is restored
- UPS is shutting down
- UPS load exceeds 90%
- Monitor startup/shutdown
- Connection failures to apcupsd
The service provides REST API endpoints for external monitoring:
GET /health- Health check (returns simple health status)GET /status- Full UPS status (returns all apcupsd data)
# Check service health
curl http://localhost:8080/health
# Get full UPS status
curl http://localhost:8080/status# Build and run with Docker Compose
docker compose up --build
# Run in background
docker compose up --build -d
# View logs
docker compose logs -f# Test connection to apcupsd
python3 test_apcupsd.py
# Test full monitoring
python3 test_monitor.pyThe container includes health checks that verify connection to apcupsd daemon.
Check health status:
docker compose ps
# or
docker inspect apcupsd-uptime-kuma-bridge --format='{{.State.Health.Status}}'- Verify
APCUPSD_HOSTandAPCUPSD_PORTsettings - Ensure apcupsd is configured to accept network connections:
# In apcupsd.conf NETSERVER on NISIP 0.0.0.0 NISPORT 3551 - Check firewall rules on apcupsd server
- Test connection manually:
telnet your-apcupsd-host 3551
- Verify
UPTIME_KUMA_PUSH_URLis correct (if using Uptime Kuma mode) - Test the URL manually:
curl "YOUR_PUSH_URL&status=up&msg=test" - Check Uptime Kuma logs for errors
- Increase
POLL_INTERVALto reduce polling frequency - Increase
HEARTBEAT_INTERVALto reduce notification frequency
Pre-built multi-architecture Docker images are available:
- GitHub Container Registry:
ghcr.io/hedger/apcupsd-uptime-kuma-bridge:latest - Architectures:
linux/amd64,linux/arm64 - Tags:
latest,main, version tags (e.g.,v1.0.0)
- Container runs as non-root user
- Minimal attack surface with distroless-style base image
- No sensitive data stored in container
- Network access limited to apcupsd and Uptime Kuma
Use with Home Assistant via Uptime Kuma integration:
# configuration.yaml
binary_sensor:
- platform: uptime_kuma
url: "https://your-kuma.domain.com"
api_key: "your-api-key"Extend the script to expose metrics for Prometheus:
# Add to upsmon.py
from prometheus_client import start_http_server, Gauge
battery_charge = Gauge('ups_battery_charge_percent', 'UPS battery charge percentage')
load_percent = Gauge('ups_load_percent', 'UPS load percentage')- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
- apcupsd - APC UPS daemon
- Uptime Kuma - Self-hosted monitoring tool
- aiohttp - Async HTTP client/server