# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['pysmartmeter', 'pysmartmeter.tests', 'pysmartmeter.utilities']

package_data = \
{'': ['*']}

install_requires = \
['bx_py_utils', 'paho-mqtt', 'pyserial', 'rich', 'typer']

entry_points = \
{'console_scripts': ['pysmartmeter = pysmartmeter.main:main']}

setup_kwargs = {
    'name': 'pysmartmeter',
    'version': '0.2.1rc1',
    'description': 'Collect data from Hichi Smartmeter and expose it via MQTT',
    'long_description': '# pysmartmeter\n\nCollect data from Hichi Smartmeter aka `volkszaehler.org` (USB Version) and expose it via MQTT.\n[![tests](https://github.com/jedie/pysmartmeter/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/jedie/pysmartmeter/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/github/jedie/pysmartmeter/branch/main/graph/badge.svg)](https://codecov.io/github/jedie/pysmartmeter)\n[![pysmartmeter @ PyPi](https://img.shields.io/pypi/v/pysmartmeter?label=pysmartmeter%20%40%20PyPi)](https://pypi.org/project/pysmartmeter/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/pysmartmeter)](https://github.com/jedie/pysmartmeter/blob/main/pyproject.toml)\n[![License GPL-3.0-or-later](https://img.shields.io/pypi/l/pysmartmeter)](https://github.com/jedie/pysmartmeter/blob/main/LICENSE)\n\nIn the end it can looks like the following [Home Assistant](https://www.home-assistant.io/) dashboard screenshot, using [MQTT integration](https://www.home-assistant.io/integrations/mqtt):\n\n![2022-11-21_13-47.png](https://raw.githubusercontent.com/jedie/jedie.github.io/master/screenshots/pysmartmeter/2022-11-21_13-47.png "2022-11-21_13-47.png")\n\nWith my "eBZ DD3" energy meterby eBZ GmbH the values update live every second ;)\n\n\n## quickstart\n\nInstall minimum requirements, e.g.:\n```bash\n~$ sudo apt install make python3-venv\n```\n\nClone sources and install project:\n```bash\n~$ git clone https://github.com/jedie/pysmartmeter.git\n~$ cd pysmartmeter\n~/pysmartmeter$ make install-poetry\n~/pysmartmeter$ make install\n~/pysmartmeter$ ./cli.sh --help\n+ exec .venv/bin/python -m pysmartmeter --help\nPySmartMeter v0.1.0\n\n Usage: python -m pysmartmeter [OPTIONS] COMMAND [ARGS]...\n\n╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────╮\n│ --install-completion        [bash|zsh|fish|powershell|pwsh]  Install completion for the specified │\n│                                                              shell.                               │\n│                                                              [default: None]                      │\n│ --show-completion           [bash|zsh|fish|powershell|pwsh]  Show completion for the specified    │\n│                                                              shell, to copy it or customize the   │\n│                                                              installation.                        │\n│                                                              [default: None]                      │\n│ --help                                                       Show this message and exit.          │\n╰───────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ Commands ────────────────────────────────────────────────────────────────────────────────────────╮\n│ check-code-style                                                                                  │\n│ coverage                     Run and show coverage.                                               │\n│ debug-settings               Display (anonymized) MQTT server username and password               │\n│ debug-systemd-service        Just print the systemd service file content                          │\n│ detect-serial                Just print the detected serial port instance                         │\n│ dump                         Just dump serial output                                              │\n│ fix-code-style               Fix code style via darker                                            │\n│ mypy                         Run Mypy (configured in pyproject.toml)                              │\n│ publish-loop                 Publish current data via MQTT (endless loop)                         │\n│ setup-systemd-service        Setup PySmartMeter systemd services and starts it.                   │\n│ store-settings               Store MQTT server settings.                                          │\n│ systemd-status               Call systemd status of PySmartMeter services                         │\n│ systemd-stop                 Stop PySmartMeter systemd services                                   │\n│ test                         Run unittests                                                        │\n╰───────────────────────────────────────────────────────────────────────────────────────────────────╯\n```\n\nTest if you Hichi Smartmeter with CP2102 USB to UART Bridge Controller will be found, e.g.:\n```bash\n~/pysmartmeter$ ./cli.sh detect-serial\n```\n\nMaybe you didn\'t have permissions to access the port, e.g.:\n```bash\n~/pysmartmeter$ ./cli.sh dump\n...\ntry: /dev/ttyUSB0 CP2102 USB to UART Bridge Controller - CP2102 USB to UART Bridge Controller USB VID:PID=10C4:EA60\n/dev/ttyUSB0 file mode: 0o20660\n/dev/ttyUSB0 user ID: 0\n/dev/ttyUSB0 user group ID: 20\n/dev/ttyUSB0 user group: \'dialout\'\nERROR: [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: \'/dev/ttyUSB0\'\n...\n```\n\nFix fiy by add the user to the group, e.g.:\n```bash\nsudo usermod -a -G dialout $USER\n```\n\n## publish smartmeter data via MQTT\n\nYou have to store your MQTT settings (host, port, username, password) one time, e.g.:\n```bash\n~/pysmartmeter$ ./cli.sh store-settings\n```\nThis will create a JSON file here: `~/.pysmartmeter`\n\nYou can test reading this settings file with:\n```bash\n~/pysmartmeter$ ./cli.sh debug-settings\n```\n\nSetup systemd service:\n```bash\n~/pysmartmeter$ sudo ./cli.sh setup-systemd-service\n```\nThis will create a systemd service that automaticly starts on every boot.\n\nCheck if service is running:\n```bash\n~/pysmartmeter$ sudo ./cli.sh systemd-status\n```\n\nIf everything is fine: Go to your [Home Assistant and check the MQTT integration](https://www.home-assistant.io/integrations/mqtt/)\nThe device discovery will be made automaticly.\n\n# various links\n\n* https://github.com/pyserial/pyserial\n* https://github.com/eclipse/paho.mqtt.python\n* https://github.com/eclipse/mosquitto\n* https://dewiki.de/Lexikon/OBIS-Kennzahlen (de) | https://www.promotic.eu/en/pmdoc/Subsystems/Comm/PmDrivers/IEC62056_OBIS.htm (en)\n* https://www.photovoltaikforum.com/thread/145886-habe-lesk%C3%B6pfe-mit-usb-%C3%BCber/ (de)\n* https://www.heise.de/tests/Ausprobiert-Guenstiger-IR-Lesekopf-fuer-Smart-Meter-mit-Tastmota-Firmware-7065559.html (de)\n* https://www.home-assistant.io\n',
    'author': 'Jens Diemer',
    'author_email': 'pysmartmeter@jensdiemer.de',
    'maintainer': 'Jens Diemer',
    'maintainer_email': 'pysmartmeter@jensdiemer.de',
    'url': 'https://github.com/jedie/pysmartmeter',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.9,<4.0.0',
}


setup(**setup_kwargs)
