Skip to content

Commit

Permalink
New readme, and a version bump, and improvements to the package and u…
Browse files Browse the repository at this point in the history
…pload script.
  • Loading branch information
tjhowse committed Jan 2, 2021
1 parent 0618908 commit 1ff98ad
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions modbus4mqtt/modbus4mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion modbus4mqtt/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version="0.4.1"
version="0.4.2"
4 changes: 4 additions & 0 deletions package_and_upload.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 1ff98ad

Please sign in to comment.