https://github.com/d1ceward/shellyplug-exporter
Prometheus Exporter for Shelly plugs
https://github.com/d1ceward/shellyplug-exporter
docker plug prometheus prometheus-exporter shelly
Last synced: about 1 year ago
JSON representation
Prometheus Exporter for Shelly plugs
- Host: GitHub
- URL: https://github.com/d1ceward/shellyplug-exporter
- Owner: d1ceward
- License: mit
- Created: 2022-02-15T23:58:48.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-03-12T20:24:35.000Z (about 1 year ago)
- Last Synced: 2025-03-31T05:33:06.223Z (about 1 year ago)
- Topics: docker, plug, prometheus, prometheus-exporter, shelly
- Language: Crystal
- Homepage: https://d1ceward.github.io/shellyplug-exporter
- Size: 232 KB
- Stars: 13
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README

# shellyplug-exporter (v1.10.1)

[](https://hub.docker.com/r/d1ceward/shellyplug-exporter)
[](https://github.com/d1ceward/shellyplug-exporter/issues)
[](https://github.com/d1ceward/shellyplug-exporter/blob/master/LICENSE)
Prometheus exporter for Shelly plugs model S written in Crystal.
> **Note** It uses the api provided by the plug, it does not use the MQTT protocol
:rocket: Suggestions for new improvements are welcome in the issue tracker.
## Installation and Usage
The `SHELLYPLUG_HOST` environment variable is required to retrieve information from the plug, `SHELLYPLUG_PORT` is optional (default 80).
Authentication variables `SHELLYPLUG_AUTH_USERNAME` and `SHELLYPLUG_AUTH_PASSWORD` depend on whether http authentication is enabled on the plug.
The `shellyplug-exporter` listens on HTTP port 5000 by default. See the environment variable `EXPORTER_PORT` to change this behavior.
### Docker
With `docker run` command :
```shell
docker run -d \
-p 8080:5000 \
-e SHELLYPLUG_HOST="shelly-plug-hostname-or-ip" \
-e SHELLYPLUG_PORT="80" \
-e SHELLYPLUG_AUTH_USERNAME="username-for-http-auth" \
-e SHELLYPLUG_AUTH_PASSWORD="password-for-http-auth" \
-e EXPORTER_PORT=5000 \
ghcr.io/d1ceward/shellyplug-exporter:latest # Or with Docker Hub: d1ceward/shellyplug-exporter:latest
```
With docker-compose file :
```yaml
---
services:
plug_exporter:
image: ghcr.io/d1ceward/shellyplug-exporter:latest # Or with Docker Hub: d1ceward/shellyplug-exporter:latest
restart: unless-stopped
ports:
- 8080:5000
environment:
SHELLYPLUG_HOST: shelly-plug-hostname-or-ip
SHELLYPLUG_PORT: 80
SHELLYPLUG_AUTH_USERNAME: username-for-http-auth
SHELLYPLUG_AUTH_PASSWORD: password-for-http-auth
EXPORTER_PORT: 5000
```
### Linux
Download the executable file :
```shell
wget --no-verbose -O shellyplug-exporter https://github.com/d1ceward/shellyplug-exporter/releases/download/v1.10.1/shellyplug-exporter-linux-amd64
```
Modify the executable's permissions :
```shell
chmod +x shellyplug-exporter
```
Execution example :
```shell
shellyplug-exporter run \
--plug-host=shelly-plug-hostname-or-ip \
--plug-port=80 \
--plug-auth-username=username-for-http-auth \
--plug-auth-password=password-for-http-auth \
--port 5000
```
Documentation available here : https://d1ceward.github.io/shellyplug-exporter/
## Metrics
Base path: `/metrics`
Name | Description | Type |
-----------------------|--------------------------------------|---------|
shellyplug_power | Current power drawn in watts | Gauge |
shellyplug_overpower | Overpower drawn in watts | Gauge |
shellyplug_total_power | Total power consumed in watt-minute | Counter |
shellyplug_temperature | Plug temperature in celsius | Gauge |
shellyplug_uptime | Plug uptime in seconds | Gauge |
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/d1ceward/shellyplug-exporter. By contributing you agree to abide by the Code of Merit.
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Development building and running
1. Install corresponding version of Crystal lang (cf: `.crystal-version` file)
2. Install Crystal dependencies with `shards install`
3. Build with `shards build`
The newly created binary should be at `bin/shellyplug-exporter`
### Running tests
```shell
crystal spec
```
## Contributors
- [d1ceward](https://github.com/d1ceward) - creator and maintainer