prometheus-hass-sun2k


Nameprometheus-hass-sun2k JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://pypi.org/project/prometheus-hass-sun2k/
SummaryPrometheus exporter for HomeAssistant data on Huawei SUN2000 inverters
upload_time2024-04-12 12:22:01
maintainerNone
docs_urlNone
authorNiko Ehrenfeuchter
requires_python<4.0,>=3.8
licenseMIT
keywords prometheus metrics homeassistant sun2k huawei solar solar-energy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 📊🏠🔌☀ HomeAssistant Huawei SUN2000 Exporter

[Prometheus][1] exporter providing metrics from a HomeAssistant instance about a
Huawei SUN2000 inverter.

## Why?

- HomeAssistant's Prometheus integration is currently broken (see [issue #80656][2]
  and [issue #104803][3] for example).
- The SUN2000's TCP modbus interface can always just talk to *one* single client
  at a time, therefore using a direct modbus connection to the inverter would
  interfere with HomeAssistant's data scraping.
- HomeAssistant provides stats through its built-in API anyway, so let's use them.

Until there is a better solution, this workaround does the job.

## ⚙🔧 How? ⚙🔧

Example installation on Debian / Ubuntu:

```bash
### all commands run as "root" or using "sudo" ###

# required for creating Python virtualenvs:
apt update
apt install -y python3-venv

# create a virtualenv in /opt:
python3 -m venv /opt/prometheus-hass-sun2k

# update 'pip' and install the 'prometheus-hass-sun2k' package:
/opt/prometheus-hass-sun2k/bin/pip install --upgrade pip
/opt/prometheus-hass-sun2k/bin/pip install prometheus-hass-sun2k
```

## 🏃 Running in foreground mode 🏃

Create a configuration file by copying the [config-example.yaml][4] file to e.g.
`config.yaml` and adjust the settings there. Then run the exporter (from within
the activated venv or using the full path) like this:

```bash
prometheus-hass-sun2k -vvv --config config.yaml
```

The exporter running in foreground can be terminated as usual via `Ctrl+C`.

## 👟 Running as a service 👟

```bash
# create a system user for running the service:
adduser --system --group has2k-exporter

# copy the configuration example, adjust permissions and edit it:
cp -v /opt/prometheus-hass-sun2k/lib/python*/site-packages/prometheus_hass_sun2k/resources/config-example.yaml /opt/prometheus-hass-sun2k/config.yaml
chgrp has2k-exporter /opt/prometheus-hass-sun2k/config.yaml
chmod 640 /opt/prometheus-hass-sun2k/config.yaml
editor /opt/prometheus-hass-sun2k/config.yaml

# install, register and adjust the systemd unit file:
cp -v /opt/prometheus-hass-sun2k/lib/python*/site-packages/prometheus_hass_sun2k/resources/systemd/prometheus-hass-sun2k.service  /etc/systemd/system/
systemctl daemon-reload
systemctl edit prometheus-hass-sun2k.service
```

The last command will open an editor with the override configuration of the
service's unit file. Check the values from the provided example script (e.g.
paths) and adjust as necessary.

Finally enable the service and start it right away. The second line will show
the log messages on the console until `Ctrl+C` is pressed. This way you should
be able to tell if the service has started up properly and is providing metrics
on the configured port:

```bash
systemctl enable --now prometheus-hass-sun2k.service
journalctl --follow --unit prometheus-hass-sun2k
```

## 🆙 Upgrading 🆙

Assuming the exporter has been installed as described above, an upgrade to a
newer version could be done like this:

```bash
/opt/prometheus-hass-sun2k/bin/pip install --upgrade prometheus-hass-sun2k
# check the changelog for potentially new configuration settings, integrate them
# if necessary and finally restart the service:
systemctl restart prometheus-hass-sun2k.service
```

[1]: https://prometheus.io/
[2]: https://github.com/home-assistant/core/issues/80656
[3]: https://github.com/home-assistant/core/issues/104803
[4]: resources/config-example.yaml

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/prometheus-hass-sun2k/",
    "name": "prometheus-hass-sun2k",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "prometheus, metrics, homeassistant, sun2k, huawei, solar, solar-energy",
    "author": "Niko Ehrenfeuchter",
    "author_email": "mail@he1ix.org",
    "download_url": "https://files.pythonhosted.org/packages/65/92/f92cb2a2adacf4503d42d9ba41df82589e947fdd1afce8ddc7258ee2bca0/prometheus_hass_sun2k-0.2.0.tar.gz",
    "platform": null,
    "description": "# \ud83d\udcca\ud83c\udfe0\ud83d\udd0c\u2600 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## \u2699\ud83d\udd27 How? \u2699\ud83d\udd27\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## \ud83c\udfc3 Running in foreground mode \ud83c\udfc3\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## \ud83d\udc5f Running as a service \ud83d\udc5f\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## \ud83c\udd99 Upgrading \ud83c\udd99\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",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Prometheus exporter for HomeAssistant data on Huawei SUN2000 inverters",
    "version": "0.2.0",
    "project_urls": {
        "Changelog": "https://github.com/ehrenfeu/prometheus-hass-sun2k/blob/main/CHANGELOG.md",
        "Homepage": "https://pypi.org/project/prometheus-hass-sun2k/",
        "Repository": "https://github.com/ehrenfeu/prometheus-hass-sun2k"
    },
    "split_keywords": [
        "prometheus",
        " metrics",
        " homeassistant",
        " sun2k",
        " huawei",
        " solar",
        " solar-energy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b09ac8f5c57352a93ceb2fc0440b922ca27152ff0c7054f2e92da35daf8d3d9f",
                "md5": "3e454855b4d9425749dc019e0a18e9fa",
                "sha256": "9eeb3eec2ccdbf8d90e64044ac97505b3b14615f96fc9cb00d5a94f6292ad933"
            },
            "downloads": -1,
            "filename": "prometheus_hass_sun2k-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3e454855b4d9425749dc019e0a18e9fa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 8905,
            "upload_time": "2024-04-12T12:21:59",
            "upload_time_iso_8601": "2024-04-12T12:21:59.093648Z",
            "url": "https://files.pythonhosted.org/packages/b0/9a/c8f5c57352a93ceb2fc0440b922ca27152ff0c7054f2e92da35daf8d3d9f/prometheus_hass_sun2k-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6592f92cb2a2adacf4503d42d9ba41df82589e947fdd1afce8ddc7258ee2bca0",
                "md5": "9d9b90f421f98466411d003bb5ab1817",
                "sha256": "65d982e78d461eab78a23ab0aa1bee9bb4e11b1b6049b1f85679be6d15042abb"
            },
            "downloads": -1,
            "filename": "prometheus_hass_sun2k-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9d9b90f421f98466411d003bb5ab1817",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 6695,
            "upload_time": "2024-04-12T12:22:01",
            "upload_time_iso_8601": "2024-04-12T12:22:01.383507Z",
            "url": "https://files.pythonhosted.org/packages/65/92/f92cb2a2adacf4503d42d9ba41df82589e947fdd1afce8ddc7258ee2bca0/prometheus_hass_sun2k-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-12 12:22:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ehrenfeu",
    "github_project": "prometheus-hass-sun2k",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "prometheus-hass-sun2k"
}
        
Elapsed time: 0.23664s