shellyplug-exporter v2.0.0

Prometheus Exporter for Shelly plugs

shellyplug-exporter (v2.0.0)

GitHub Workflow Status (main) Docker Pulls GHCR GitHub issues GitHub license

Prometheus exporter for Shelly Plug S, written in Crystal.

Note Uses the plug’s HTTP API (not MQTT).

🚀 Feature requests and suggestions are welcome, open an issue!

Quick Start

1. YAML Configuration (Recommended)

Manage multiple plugs easily with a config.yaml file.

Create config.yaml:

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

Run the exporter:

shellyplug-exporter run --config config.yaml

2. Environment Variables (Legacy, Single Plug)

Set variables for a single plug:

  • SHELLYPLUG_HOST (required)
  • SHELLYPLUG_PORT (default: 80)
  • SHELLYPLUG_AUTH_USERNAME / SHELLYPLUG_AUTH_PASSWORD (if needed)
  • EXPORTER_PORT (default: 5000)

Example:

shellyplug-exporter run --port 5000

3. Docker Usage

With config.yaml:

docker run -d \
  -p 8080:5000 \
  -v $(pwd)/config.yaml:/config.yaml \
  ghcr.io/d1ceward/shellyplug-exporter:latest \
  shellyplug-exporter run --config /config.yaml

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 environment variables:

docker run -d \
  -p 8080:5000 \
  -e SHELLYPLUG_HOST="shelly-plug-hostname-or-ip" \
  -e SHELLYPLUG_PORT="80" \
  -e SHELLYPLUG_AUTH_USERNAME="username" \
  -e SHELLYPLUG_AUTH_PASSWORD="password" \
  -e EXPORTER_PORT=5000 \
  ghcr.io/d1ceward/shellyplug-exporter:latest

4. Linux Binary

Download:

wget --no-verbose -O shellyplug-exporter https://github.com/d1ceward/shellyplug-exporter/releases/download/v2.0.0/shellyplug-exporter-linux-amd64
chmod +x shellyplug-exporter

Run:

shellyplug-exporter run --port 5000

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.

  1. Fork: github.com/d1ceward/shellyplug-exporter
  2. Create a branch: git checkout -b my-new-feature
  3. Commit: git commit -am 'Add some feature'
  4. Push: git push origin my-new-feature
  5. Open a Pull Request

Development

  1. Install Crystal (see .crystal-version)
  2. Install dependencies: shards install
  3. Build: shards build
  4. Binary: bin/shellyplug-exporter

Run tests:

crystal spec

Documentation

See: d1ceward.github.io/shellyplug-exporter

Contributors

Repository

shellyplug-exporter

Owner
Statistic
  • 12
  • 3
  • 1
  • 0
  • 2
  • about 2 hours ago
  • February 15, 2022
License

MIT License

Links
Synced at

Fri, 29 Aug 2025 06:15:20 GMT

Languages