{"id":23094874,"url":"https://github.com/mayniklas/shelly-exporter","last_synced_at":"2025-08-16T10:33:10.902Z","repository":{"id":37426374,"uuid":"497285016","full_name":"MayNiklas/shelly-exporter","owner":"MayNiklas","description":"A Shelly power metrics exporter written in golang. Currently only tested for Shelly Plug S.","archived":false,"fork":false,"pushed_at":"2024-03-31T08:40:36.000Z","size":216,"stargazers_count":11,"open_issues_count":4,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-21T01:05:28.516Z","etag":null,"topics":["exporter","grafana","nix-flake","power-meter","prometheus","prometheus-exporter","prometheus-metrics","shelly","shelly-plug-s"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MayNiklas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-28T10:28:07.000Z","updated_at":"2024-06-19T20:06:05.597Z","dependencies_parsed_at":"2024-06-19T20:05:54.768Z","dependency_job_id":"deca7082-0a9d-4813-b631-0c5a9ea90f3f","html_url":"https://github.com/MayNiklas/shelly-exporter","commit_stats":{"total_commits":139,"total_committers":5,"mean_commits":27.8,"dds":"0.38129496402877694","last_synced_commit":"24e8a12f229f86c08ec00d86b3986c6466eb9692"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayNiklas%2Fshelly-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayNiklas%2Fshelly-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayNiklas%2Fshelly-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MayNiklas%2Fshelly-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MayNiklas","download_url":"https://codeload.github.com/MayNiklas/shelly-exporter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230032694,"owners_count":18162491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["exporter","grafana","nix-flake","power-meter","prometheus","prometheus-exporter","prometheus-metrics","shelly","shelly-plug-s"],"created_at":"2024-12-16T22:18:32.308Z","updated_at":"2024-12-16T22:18:35.458Z","avatar_url":"https://github.com/MayNiklas.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shelly-exporter\n\nA Shelly power metrics exporter written in golang.\nCurrently only tested for Shelly Plug S.\n\n[![go tests](https://github.com/MayNiklas/shelly-exporter/actions/workflows/go-tests.yml/badge.svg?branch=main)](https://github.com/MayNiklas/shelly-exporter/actions/workflows/go-tests.yml)\n\n![Docker Pulls](https://img.shields.io/docker/pulls/mayniki/shelly-exporter)\n![Docker Image Size with architecture (latest by date/latest semver)](https://img.shields.io/docker/image-size/mayniki/shelly-exporter)\n\n## Available metrics\n\nName     | Description\n---------|------------\nshelly_power_current | Current real AC power being drawn, in Watts\nshelly_power_total | Total energy consumed by the attached electrical appliance in Watt-minute\nshelly_temperature | internal device temperature in °C\nshelly_update_available | Info whether newer firmware version is available\nshelly_uptime | Seconds elapsed since boot\n\nAll metrics include the following labels:\n\n* device IP\n* device name\n* device hostname\n\n## How to execute for development purposes\n\nMetrics will be exposed on: http://localhost:8080/probe?target=http://\u003cshelly_ip\u003e\n\n### Nix / NixOS\n\nThis repository contains a `flake.nix` file.\n\n```sh\n# run the package\nnix run .#shelly_exporter\n\n# build the package\nnix build .#shelly_exporter\n```\n\n### General\n\nMake sure [golang](https://go.dev) is installed.\n\n```sh\n# run application\ngo run .\n\n# build application\ngo build\n\n# execute tests\ngo test -v ./...\n\n# show test coverage\ngo test -covermode=count -coverpkg=./... -coverprofile cover.out -v ./...\ngo tool cover -html cover.out -o cover.html\n```\n\n## How to install\n\n### NixOS\n\n1. Add this repository to your `flake.nix`:\n\n```nix\n{\n  inputs.shelly-exporter = {\n    url = \"github:MayNiklas/shelly-exporter\";\n    inputs = { nixpkgs.follows = \"nixpkgs\"; };\n  };\n}\n```\n\n2. Enable the service \u0026 the prometheus scraper in your configuration:\n\n```nix\n{ shelly-exporter, ... }: {\n\n  imports = [ shelly-exporter.nixosModules.default ];\n\n  services.shelly-exporter = {\n    enable = true;\n    port = \"8080\";\n    listen = \"localhost\";\n    user = \"shelly-exporter\";\n    group = \"shelly-exporter\";\n\n    configure-prometheus = true;\n    targets = [\n      \"http://192.168.0.2\"\n      \"http://192.168.0.3\"\n      \"http://192.168.0.4\"\n      \"http://192.168.0.5\"\n      \"http://192.168.0.6\"\n      \"http://192.168.0.7\"\n    ];\n  };\n}\n```\n\n### Docker\n\nDocker builds for this project are available on [Docker Hub](https://hub.docker.com/r/mayniki/shelly-exporter).\nCurrently amd64 and arm64 are supported.\n\nThe following environment variables are available:\n\n* `listen` - The address to listen on. Defaults to `8080`\n* `port` - The port to listen on. Defaults to `8080`\n\nOf course, both parameters can be achieved by using a different port forwarding configuration.\n\n```sh\ndocker run -d --rm -p 8080:8080 mayniki/shelly-exporter:v1.0.2\n```\n\nFor docker-compose, the following configuration can be used:\n\n```yml\nversion: \"3.9\"\nservices:\n  shelly-exporter:\n    image: mayniki/shelly-exporter:v1.0.2\n    container_name: shelly-exporter\n    restart: unless-stopped\n    ports:\n      - 8080:8080\n```\n\nAfter starting the container, all metrics will be available on `http://localhost:8080/probe?target=http://\u003cshelly_ip\u003e`.\nSince the container itself is stateless, all configuration has to be done by your prometheus configuration:\n\n```yml\n- job_name: shelly\n  scrape_interval: 15s\n  scrape_timeout: 10s\n  metrics_path: /probe\n  scheme: http\n  relabel_configs:\n  - source_labels: [__address__]\n    separator: ;\n    regex: (.*)\n    target_label: __param_target\n    replacement: $1\n    action: replace\n  - source_labels: [__param_target]\n    separator: ;\n    regex: (.*)\n    target_label: instance\n    replacement: $1\n    action: replace\n  - separator: ;\n    regex: (.*)\n    target_label: __address__\n    replacement: 127.0.0.1:8080\n    action: replace\n  static_configs:\n  - targets:\n    - http://192.168.0.2\n    - http://192.168.0.3\n    - http://192.168.0.4\n    - http://192.168.0.5\n    - http://192.168.0.6\n    - http://192.168.0.7\n```\n\n### Libaries used\n\n- https://github.com/prometheus/client_golang\n\n### Libary documentation\n\n- https://pkg.go.dev/github.com/prometheus/client_golang/prometheus\n\n### API documentation\n\n- https://shelly-api-docs.shelly.cloud/gen1/#shelly-plug-plugs-status\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayniklas%2Fshelly-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayniklas%2Fshelly-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayniklas%2Fshelly-exporter/lists"}