From 1ff98adf3b692a45e6d5a85291b746650bd592f6 Mon Sep 17 00:00:00 2001 From: Travis Howse Date: Sat, 2 Jan 2021 21:39:36 +1000 Subject: [PATCH] New readme, and a version bump, and improvements to the package and upload script. --- README.md | 10 +++++++++- modbus4mqtt/modbus4mqtt.py | 12 ++++++------ modbus4mqtt/version.py | 2 +- package_and_upload.sh | 4 ++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e0d27ab..980996f 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,22 @@ be a complete solution. ## Installation +### Python module + ```bash $ pip3 install --user modbus4mqtt $ modbus4mqtt --help ``` +### Docker container + Alternatively you can run Modbus4MQTT in a Docker container. A [Dockerfile](./Dockerfile) example is provided. -You will need to provide the credentials to connect to your MQTT broker, as well as a path to a YAML file that defines the memory map of your Modbus device. You can download these YAML files from this project's github repo. +```bash +$ docker pull tjhowse/modbus4mqtt:latest +$ docker run modbus4mqtt --help +``` +When launching inside the docker container you will either need to use one of the built-in YAMLs like `/modbus4mqtt/modbus4mqtt/Sungrow_SH5k_20.yaml`, or map your custom YAML into the container in a volume. ## YAML definition diff --git a/modbus4mqtt/modbus4mqtt.py b/modbus4mqtt/modbus4mqtt.py index f35b530..9cb3ded 100755 --- a/modbus4mqtt/modbus4mqtt.py +++ b/modbus4mqtt/modbus4mqtt.py @@ -229,12 +229,12 @@ def loop_forever(self): sleep(self.config['update_rate']) @click.command() -@click.option('--hostname', default='localhost', help='The hostname or IP address of the MQTT server.') -@click.option('--port', default=1883, help='The hostname or IP address of the MQTT server.') -@click.option('--username', default='username', help='The hostname or IP address of the MQTT server.') -@click.option('--password', default='password', help='The hostname or IP address of the MQTT server.') -@click.option('--config', default='./Sungrow_SH5k_20.yaml', help='The YAML config file for your modbus device.') -@click.option('--mqtt_topic_prefix', default='modbus4mqtt', help='Prefixed to everything this publishes') +@click.option('--hostname', default='localhost', help='The hostname or IP address of the MQTT server.', show_default=True) +@click.option('--port', default=1883, help='The port of the MQTT server.', show_default=True) +@click.option('--username', default='username', help='The username to authenticate to the MQTT server.', show_default=True) +@click.option('--password', default='password', help='The password to authenticate to the MQTT server.', show_default=True) +@click.option('--config', default='./Sungrow_SH5k_20.yaml', help='The YAML config file for your modbus device.', show_default=True) +@click.option('--mqtt_topic_prefix', default='modbus4mqtt', help='A prefix for published MQTT topics.', show_default=True) def main(hostname, port, username, password, config, mqtt_topic_prefix): logging.basicConfig( format='%(asctime)s %(levelname)-8s %(message)s', diff --git a/modbus4mqtt/version.py b/modbus4mqtt/version.py index e2c7ee4..e242c1b 100644 --- a/modbus4mqtt/version.py +++ b/modbus4mqtt/version.py @@ -1 +1 @@ -version="0.4.1" +version="0.4.2" diff --git a/package_and_upload.sh b/package_and_upload.sh index f71d211..3ab3244 100755 --- a/package_and_upload.sh +++ b/package_and_upload.sh @@ -1,5 +1,9 @@ #!/bin/bash +version=v`cat ./modbus4mqtt/version.py | cut -d\" -f2` rm ./dist/modbus4mqtt*.whl rm ./dist/modbus4mqtt*.tar.gz python3 setup.py sdist bdist_wheel python3 -m twine upload dist/* +docker build -t tjhowse/modbus4mqtt:latest -t tjhowse/modbus4mqtt:"$version" . +docker push tjhowse/modbus4mqtt:latest +docker push tjhowse/modbus4mqtt:"$version"