ggiblin/hubitat-exporter: hubitat-prometheus-gateway - Bash Script and Kubernetes Pod
Hubitat Prometheus Exporter
This repo offers two solutions to get the Hubitat Metrics into Prometheus
- Standalone Bash Script
- Kubernetes Pod (in the k8s subdirectory)
A lightweight Bash-based Prometheus exporter for Hubitat Elevation smart home hub metrics. This exporter collects device states and metrics from your Hubitat hub and exposes them in Prometheus format.
Features
- Exports device states (on/off, temperature, humidity, etc.)
- Supports multiple device types and attributes
- Updates metrics every 15 seconds
- Minimal dependencies (uses common Unix tools)
- Handles concurrent connections efficiently
- Automatic reconnection on errors
Prerequisites
The following tools must be installed:
curljqsocatbase64
Configuration
Create a .env file in the same directory as the script with the following variables:
HE_URI=http://your-hubitat-ip/apps/api/26/devices HE_TOKEN=your-access-token
Replace your-hubitat-ip with your Hubitat hub's IP address and your-access-token with your Maker API access token.
Installation
- Clone this repository
- Make the script executable:
chmod +x hubitat-exporter.sh
- Create and configure the
.envfile as described above - Run the exporter:
./hubitat-exporter.sh
Exported Metrics
The exporter provides the following metrics:
hubitat_up- Indicates if the connection to Hubitat is up (1) or down (0)hubitat_device_switch- Switch state (1=on, 0=off)hubitat_device_battery- Battery level percentagehubitat_device_temperature- Temperature readinghubitat_device_humidity- Humidity percentagehubitat_device_illuminance- Light levelhubitat_device_power- Power consumption in wattshubitat_device_energy- Energy consumptionhubitat_device_motion- Motion detection state (1=active, 0=inactive)hubitat_device_contact- Contact sensor state (1=open, 0=closed)
All metrics include the following labels:
hub- Hub nameid- Device IDlabel- Device labelroom- Room nametype- Device type
Usage
The exporter runs on port 5000 by default. To test:
curl http://localhost:5000/metrics
Prometheus Configuration
Add the following to your prometheus.yml:
scrape_configs: - job_name: 'hubitat' static_configs: - targets: ['localhost:5000'] scrape_interval: 30s
Logging
The exporter logs its activity to stderr with timestamps. You can:
- View logs in real-time by running the script directly:
./hubitat-exporter.sh
- Redirect logs to a file while running in the background:
./hubitat-exporter.sh 2>/var/log/hubitat-exporter.log &
- Follow the logs in real-time using
tail:
tail -f /var/log/hubitat-exporter.log
The logs include:
- Server start/stop events
- Metrics generation status
- API connection issues
- Error messages with details
Troubleshooting
- If the exporter fails to start, check that all required tools are installed
- Verify your Hubitat hub is accessible and the Maker API is properly configured
- Check the logs as described in the Logging section above
- Ensure the port 5000 is not in use by another application
License
This project is open source and available under the Elmer Fudd and MIT License.
About
hubitat-prometheus-gateway - Bash Script and Kubernetes Pod
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages
No packages published
Publish your first package