{"id":15286941,"url":"https://github.com/ehrenfeu/prometheus-hass-sun2k","last_synced_at":"2026-02-18T12:02:24.521Z","repository":{"id":231325923,"uuid":"781178062","full_name":"ehrenfeu/prometheus-hass-sun2k","owner":"ehrenfeu","description":"Prometheus exporter for HomeAssistant data on SUN2000 inverters.","archived":false,"fork":false,"pushed_at":"2024-04-12T12:22:09.000Z","size":40,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-13T08:08:03.679Z","etag":null,"topics":["homeassistant","huawei","prometheus","prometheus-exporter","python","solar","solar-energy","sun2000"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehrenfeu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2024-04-02T22:20:11.000Z","updated_at":"2024-09-06T17:36:43.000Z","dependencies_parsed_at":"2024-04-03T14:47:17.008Z","dependency_job_id":"87afa9da-045a-49c9-83d2-4fd29a4bf21d","html_url":"https://github.com/ehrenfeu/prometheus-hass-sun2k","commit_stats":null,"previous_names":["ehrenfeu/homeassistant-sun2k-exporter","ehrenfeu/prometheus-hass-sun2k"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ehrenfeu/prometheus-hass-sun2k","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehrenfeu%2Fprometheus-hass-sun2k","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehrenfeu%2Fprometheus-hass-sun2k/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehrenfeu%2Fprometheus-hass-sun2k/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehrenfeu%2Fprometheus-hass-sun2k/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehrenfeu","download_url":"https://codeload.github.com/ehrenfeu/prometheus-hass-sun2k/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehrenfeu%2Fprometheus-hass-sun2k/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014292,"owners_count":26085489,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["homeassistant","huawei","prometheus","prometheus-exporter","python","solar","solar-energy","sun2000"],"created_at":"2024-09-30T15:19:14.119Z","updated_at":"2025-10-13T08:08:04.608Z","avatar_url":"https://github.com/ehrenfeu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📊🏠🔌☀ HomeAssistant Huawei SUN2000 Exporter\n\n[Prometheus][1] exporter providing metrics from a HomeAssistant instance about a\nHuawei SUN2000 inverter.\n\n## Why?\n\n- HomeAssistant's Prometheus integration is currently broken (see [issue #80656][2]\n  and [issue #104803][3] for example).\n- The SUN2000's TCP modbus interface can always just talk to *one* single client\n  at a time, therefore using a direct modbus connection to the inverter would\n  interfere with HomeAssistant's data scraping.\n- HomeAssistant provides stats through its built-in API anyway, so let's use them.\n\nUntil there is a better solution, this workaround does the job.\n\n## ⚙🔧 How? ⚙🔧\n\nExample installation on Debian / Ubuntu:\n\n```bash\n### all commands run as \"root\" or using \"sudo\" ###\n\n# required for creating Python virtualenvs:\napt update\napt install -y python3-venv\n\n# create a virtualenv in /opt:\npython3 -m venv /opt/prometheus-hass-sun2k\n\n# update 'pip' and install the 'prometheus-hass-sun2k' package:\n/opt/prometheus-hass-sun2k/bin/pip install --upgrade pip\n/opt/prometheus-hass-sun2k/bin/pip install prometheus-hass-sun2k\n```\n\n## 🏃 Running in foreground mode 🏃\n\nCreate a configuration file by copying the [config-example.yaml][4] file to e.g.\n`config.yaml` and adjust the settings there. Then run the exporter (from within\nthe activated venv or using the full path) like this:\n\n```bash\nprometheus-hass-sun2k -vvv --config config.yaml\n```\n\nThe exporter running in foreground can be terminated as usual via `Ctrl+C`.\n\n## 👟 Running as a service 👟\n\n```bash\n# create a system user for running the service:\nadduser --system --group has2k-exporter\n\n# copy the configuration example, adjust permissions and edit it:\ncp -v /opt/prometheus-hass-sun2k/lib/python*/site-packages/prometheus_hass_sun2k/resources/config-example.yaml /opt/prometheus-hass-sun2k/config.yaml\nchgrp has2k-exporter /opt/prometheus-hass-sun2k/config.yaml\nchmod 640 /opt/prometheus-hass-sun2k/config.yaml\neditor /opt/prometheus-hass-sun2k/config.yaml\n\n# install, register and adjust the systemd unit file:\ncp -v /opt/prometheus-hass-sun2k/lib/python*/site-packages/prometheus_hass_sun2k/resources/systemd/prometheus-hass-sun2k.service  /etc/systemd/system/\nsystemctl daemon-reload\nsystemctl edit prometheus-hass-sun2k.service\n```\n\nThe last command will open an editor with the override configuration of the\nservice's unit file. Check the values from the provided example script (e.g.\npaths) and adjust as necessary.\n\nFinally enable the service and start it right away. The second line will show\nthe log messages on the console until `Ctrl+C` is pressed. This way you should\nbe able to tell if the service has started up properly and is providing metrics\non the configured port:\n\n```bash\nsystemctl enable --now prometheus-hass-sun2k.service\njournalctl --follow --unit prometheus-hass-sun2k\n```\n\n## 🆙 Upgrading 🆙\n\nAssuming the exporter has been installed as described above, an upgrade to a\nnewer version could be done like this:\n\n```bash\n/opt/prometheus-hass-sun2k/bin/pip install --upgrade prometheus-hass-sun2k\n# check the changelog for potentially new configuration settings, integrate them\n# if necessary and finally restart the service:\nsystemctl restart prometheus-hass-sun2k.service\n```\n\n[1]: https://prometheus.io/\n[2]: https://github.com/home-assistant/core/issues/80656\n[3]: https://github.com/home-assistant/core/issues/104803\n[4]: resources/config-example.yaml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehrenfeu%2Fprometheus-hass-sun2k","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehrenfeu%2Fprometheus-hass-sun2k","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehrenfeu%2Fprometheus-hass-sun2k/lists"}