shellyplug-exporter (v2.1.0)
Prometheus exporter for Shelly Plug S, written in Crystal.
Note Uses the plug’s HTTP API (not MQTT).
:rocket: Feature requests and suggestions are welcome, open an issue!
Quick Start
Step 1. Configure Your Plugs
Create a config.yaml to manage one or more plugs:
exporter_port: 5000
plugs:
- name: plug1
host: 192.168.33.2
port: 80
auth_username: user1
auth_password: pass1
- name: plug2
host: 192.168.33.3
port: 80
auth_username: user2
auth_password: pass2
Step 2. Run exporter
With docker
Directly using your config file:
docker run -d \
-p 8080:5000 \
-v $(pwd)/config.yaml:/config.yaml \
ghcr.io/d1ceward/shellyplug-exporter:latest \
shellyplug-exporter run --config /config.yaml
Or with docker-compose:
services:
plug_exporter:
image: ghcr.io/d1ceward/shellyplug-exporter:latest
restart: unless-stopped
ports:
- 8080:5000
volumes:
- ./config.yaml:/config.yaml
command: shellyplug-exporter run --config /config.yaml
With binary
Using your config file:
shellyplug-exporter run --config config.yaml
Legacy environment variables (Single Plug, Not recommended)
If you want to run with environment variables (for a single plug), you can use the following variables:
SHELLYPLUG_HOST
(required): IP address or hostname of the Shelly Plug SSHELLYPLUG_PORT
(optional, default: 80): Port of the Shelly Plug SSHELLYPLUG_AUTH_USERNAME
(optional): Username for HTTP Basic AuthSHELLYPLUG_AUTH_PASSWORD
(optional): Password for HTTP Basic AuthEXPORTER_PORT
(optional, default: 5000): Port for the exporter to listen on
Example with docker:
docker run -d \
-p 8080:5000 \
-e SHELLYPLUG_HOST="192.168.33.2" \
-e SHELLYPLUG_PORT="80" \
-e SHELLYPLUG_AUTH_USERNAME="user1" \
-e SHELLYPLUG_AUTH_PASSWORD="pass1" \
-e EXPORTER_PORT=5000 \
ghcr.io/d1ceward/shellyplug-exporter:latest
Metrics
Endpoint: /metrics
| Name | Description | Type | |------------------------|--------------------------------------|---------| | shellyplug_power | Current power drawn (watts) | Gauge | | shellyplug_overpower | Overpower drawn (watts) | Gauge | | shellyplug_total | Total power consumed (watt-minutes) | Counter | | shellyplug_temperature | Plug temperature (°C) | Gauge | | shellyplug_uptime | Plug uptime (seconds) | Gauge |
Multiple plugs:
Metrics include a plug
label:
shellyplug_power{plug="plug1"} 12.3
shellyplug_power{plug="plug2"} 8.7
Contributing
Bug reports and pull requests are welcome! By contributing, you agree to the Code of Merit.
- Fork: github.com/d1ceward/shellyplug-exporter
- Create a branch:
git checkout -b my-new-feature
- Commit:
git commit -am 'Add some feature'
- Push:
git push origin my-new-feature
- Open a Pull Request
Development
- Install Crystal (see
.crystal-version
) - Install dependencies:
shards install
- Build:
shards build
- Binary:
bin/shellyplug-exporter
Run tests:
crystal spec
Documentation
See: d1ceward.github.io/shellyplug-exporter
Contributors
- d1ceward – creator and maintainer