homewizard-p1-exporter-0.2.0 is not a library.
HomeWizard P1 Prometheus Exporter
A Rust-based Prometheus exporter for the HomeWizard P1 Meter, providing real-time electricity and gas consumption metrics.
Features
- 🚀 High Performance - Lightweight and efficient Rust implementation
- 📊 Real-time Monitoring - Power consumption/production metrics updated every 10 seconds
- ⚡ Power Quality Tracking - Voltage sags/swells and power failure monitoring
- 🔥 Gas Consumption - Integrated gas meter reading support
- 💰 Tariff Support - Separate metrics for peak (T1) and off-peak (T2) tariffs
- 📡 Network Monitoring - WiFi signal strength tracking
- 🐳 Docker Ready - Multi-platform images for easy deployment
- ✅ Production Ready - Comprehensive test coverage and error handling
Prerequisites
- HomeWizard P1 Meter with local API enabled
- Rust 1.88+ (for building from source)
- Docker (for container deployment)
Quick Start
# Using Docker
# Or using pre-built binary
HOMEWIZARD_HOST=192.168.1.100
Installation
Using Docker (Recommended)
# From Docker Hub
# From GitHub Container Registry
Using Pre-built Binaries
Download the latest release for your platform from the releases page.
# Example for Linux x86_64
HOMEWIZARD_HOST=192.168.1.100
Using Cargo
HOMEWIZARD_HOST=192.168.1.100
Building from Source
# Clone the repository
# Build the binary
# Run the exporter
HOMEWIZARD_HOST=192.168.1.100
Configuration
The exporter can be configured via command-line arguments or environment variables:
| Environment Variable | CLI Flag | Default | Description |
|---|---|---|---|
HOMEWIZARD_HOST |
--host |
Required | IP address or hostname of HomeWizard P1 Meter |
METRICS_PORT |
--port |
9898 |
Port to expose Prometheus metrics |
POLL_INTERVAL |
--poll-interval |
10 |
Seconds between API polls |
LOG_LEVEL |
--log-level |
info |
Log level (trace, debug, info, warn, error) |
HTTP_TIMEOUT |
--http-timeout |
5 |
HTTP request timeout in seconds |
Metrics
The exporter provides the following Prometheus metrics:
| Metric | Type | Description |
|---|---|---|
homewizard_p1_power_import_total_kwh |
Counter | Total power imported in kWh |
homewizard_p1_power_import_tariff_kwh{tariff} |
Counter | Power imported per tariff (1/2) |
homewizard_p1_power_export_total_kwh |
Counter | Total power exported in kWh |
homewizard_p1_power_export_tariff_kwh{tariff} |
Counter | Power exported per tariff (1/2) |
homewizard_p1_active_power_watts |
Gauge | Current active power in watts |
homewizard_p1_active_power_l1_watts |
Gauge | Current active power L1 in watts |
homewizard_p1_active_power_l2_watts |
Gauge | Current active power L2 in watts |
homewizard_p1_active_power_l3_watts |
Gauge | Current active power L3 in watts |
homewizard_p1_active_voltage_l1_volts |
Gauge | Current active voltage L1 in volts |
homewizard_p1_active_voltage_l2_volts |
Gauge | Current active voltage L2 in volts |
homewizard_p1_active_voltage_l3_volts |
Gauge | Current active voltage L3 in volts |
homewizard_p1_active_current_amperes |
Gauge | Current active current in amperes |
homewizard_p1_active_current_l1_amperes |
Gauge | Current active current L1 in amperes |
homewizard_p1_active_current_l2_amperes |
Gauge | Current active current L2 in amperes |
homewizard_p1_active_current_l3_amperes |
Gauge | Current active current L3 in amperes |
homewizard_p1_active_tariff |
Gauge | Currently active tariff (1 or 2) |
homewizard_p1_gas_total_m3 |
Counter | Total gas consumption in m³ |
homewizard_p1_gas_timestamp |
Gauge | Timestamp of last gas meter reading |
homewizard_p1_gas_meter_info{unique_id} |
Gauge | Gas meter information |
homewizard_p1_wifi_strength_percent |
Gauge | WiFi signal strength percentage |
homewizard_p1_voltage_sag_l1_count_total |
Counter | Total voltage sag events on L1 |
homewizard_p1_voltage_sag_l2_count_total |
Counter | Total voltage sag events on L2 |
homewizard_p1_voltage_sag_l3_count_total |
Counter | Total voltage sag events on L3 |
homewizard_p1_voltage_swell_l1_count_total |
Counter | Total voltage swell events on L1 |
homewizard_p1_voltage_swell_l2_count_total |
Counter | Total voltage swell events on L2 |
homewizard_p1_voltage_swell_l3_count_total |
Counter | Total voltage swell events on L3 |
homewizard_p1_power_failures_any_total |
Counter | Total power failures |
homewizard_p1_power_failures_long_total |
Counter | Total long power failures |
homewizard_p1_meter_info{meter_id,meter_model,smr_version,wifi_ssid} |
Gauge | Meter information |
homewizard_p1_external_sensor_value{unique_id,type,unit} |
Gauge | External sensor value |
homewizard_p1_external_sensor_timestamp{unique_id,type} |
Gauge | External sensor timestamp |
Prometheus Configuration
Add the following to your prometheus.yml:
scrape_configs:
- job_name: 'homewizard'
static_configs:
- targets:
scrape_interval: 30s
Enabling HomeWizard Local API
- Open the HomeWizard Energy app
- Go to Settings → Meters → Your P1 Meter
- Enable "Local API"
Grafana Dashboard
An example Grafana dashboard is included in grafana-dashboard.json. To import:
- Open Grafana
- Go to Dashboards → Import
- Upload the JSON file or paste its contents
- Select your Prometheus data source
- Click Import
The dashboard includes:
- Real-time power usage graph
- Current power gauge
- Total power imported/exported
- Gas consumption
- Current tariff indicator
Development
# Show all available make targets
# Build the binary
# Run tests
# Check code formatting and linting
# Run the exporter locally
HOMEWIZARD_HOST=192.168.1.100
# Build Docker image
# Run in Docker
HOMEWIZARD_HOST=192.168.1.100
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.