| Crates.io | shelly-exporter |
| lib.rs | shelly-exporter |
| version | 0.1.3 |
| created_at | 2025-07-23 14:47:41.622112+00 |
| updated_at | 2025-07-23 14:47:41.622112+00 |
| description | Prometheus exporter for Shelly smart home devices |
| homepage | https://github.com/rvben/shelly-exporter |
| repository | https://github.com/rvben/shelly-exporter |
| max_upload_size | |
| id | 1764870 |
| size | 146,460 |
A Prometheus exporter for Shelly smart home devices, supporting both Gen1 and Gen2 devices.
This exporter supports all Shelly devices with HTTP API access, including:
The exporter provides the following metrics:
| Metric | Description | Labels |
|---|---|---|
shelly_device_up |
Device availability (1=up, 0=down) | device, host, model, generation |
shelly_device_uptime_seconds |
Device uptime in seconds | device, host |
shelly_device_temperature_celsius |
Device temperature | device, host |
shelly_wifi_rssi_dbm |
WiFi signal strength | device, host, ssid |
shelly_switch_output |
Switch state (1=on, 0=off) | device, host, channel |
shelly_switch_power_watts |
Instantaneous power consumption | device, host, channel |
shelly_switch_voltage_volts |
Voltage measurement | device, host, channel |
shelly_switch_current_amps |
Current measurement | device, host, channel |
shelly_switch_power_factor |
Power factor | device, host, channel |
shelly_switch_frequency_hz |
AC frequency | device, host, channel |
shelly_switch_energy_total_wh |
Total energy consumed | device, host, channel |
shelly_system_ram_free_bytes |
Free RAM | device, host |
shelly_system_ram_total_bytes |
Total RAM | device, host |
shelly_system_fs_free_bytes |
Free filesystem space | device, host |
shelly_system_fs_total_bytes |
Total filesystem space | device, host |
shelly_device_update_available |
Firmware update availability | device, host, current_version, new_version |
docker run -d \
--name shelly-exporter \
-p 9925:9925 \
-e SHELLY_HOSTS="http://192.168.1.100,http://192.168.1.101" \
-e SHELLY_NAMES="Living Room,Kitchen" \
ghcr.io/rvben/shelly-exporter:latest
version: '3.8'
services:
shelly-exporter:
image: ghcr.io/rvben/shelly-exporter:latest
container_name: shelly-exporter
restart: unless-stopped
ports:
- "9925:9925"
environment:
SHELLY_HOSTS: "http://192.168.1.100,http://192.168.1.101"
SHELLY_NAMES: "Living Room,Kitchen"
SHELLY_LOG_LEVEL: info
SHELLY_POLL_INTERVAL: 30
# Clone the repository
git clone https://github.com/rvben/shelly-exporter
cd shelly-exporter
# Build with Cargo
cargo build --release
# Run the exporter
SHELLY_HOSTS="http://192.168.1.100" ./target/release/shelly-exporter
The exporter can be configured using command-line arguments or environment variables:
| CLI Argument | Environment Variable | Description | Default |
|---|---|---|---|
--hosts |
SHELLY_HOSTS |
Comma-separated list of device URLs (required) | - |
--names |
SHELLY_NAMES |
Comma-separated list of device names | IP addresses |
--username |
SHELLY_USERNAME |
Authentication username | admin |
--password |
SHELLY_PASSWORD |
Authentication password | - |
--port |
SHELLY_EXPORTER_PORT |
Metrics server port | 9925 |
--bind |
SHELLY_EXPORTER_BIND |
Metrics server bind address | 0.0.0.0 |
--poll-interval |
SHELLY_POLL_INTERVAL |
Poll interval in seconds | 30 |
--http-timeout |
SHELLY_HTTP_TIMEOUT |
HTTP timeout in seconds | 10 |
--log-level |
SHELLY_LOG_LEVEL |
Log level (trace/debug/info/warn/error) | info |
--enable-discovery |
SHELLY_DISCOVERY |
Enable mDNS discovery | false |
--discovery-interval |
SHELLY_DISCOVERY_INTERVAL |
Discovery interval in seconds | 300 |
Monitor multiple devices with custom names:
SHELLY_HOSTS="http://192.168.1.100,http://192.168.1.101,http://192.168.1.102" \
SHELLY_NAMES="Living Room,Kitchen,Bedroom" \
shelly-exporter
With authentication:
SHELLY_HOSTS="http://192.168.1.100" \
SHELLY_USERNAME="admin" \
SHELLY_PASSWORD="secret" \
shelly-exporter
Add the following to your prometheus.yml:
scrape_configs:
- job_name: 'shelly'
static_configs:
- targets: ['localhost:9925']
scrape_interval: 30s
A sample Grafana dashboard is available in grafana-dashboard.json. Import it into your Grafana instance to visualize:
cargo test
docker build -t shelly-exporter .
The exporter automatically detects device generation by trying Gen2 endpoints first, then Gen1. If detection fails:
Adjust the poll interval to reduce frequency of metric updates:
SHELLY_POLL_INTERVAL=60 shelly-exporter
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.