diff --git a/ReadMe.md b/ReadMe.md index b635c6c..7978719 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -38,3 +38,22 @@ Set the following parameter: ```docker run -t -i --device=/dev/ttyUSB0 -e SERIAL_DEVICE="/dev/ttyUSB0" -e MQTT_SERVER="192.168.x.y" -e MQTT_TOPIC="testtopic/" sha256:``` + +#### Execution via Docker Compose +``` +# template docker-compose.yml +services: + python_app: + attach: false + build: + context: . + dockerfile: Dockerfile + environment: + - SERIAL_DEVICE=/dev/ttyUSB0 + - MQTT_SERVER=192.168.x.y + - MQTT_TOPIC=testtopic/ + devices: + - "/dev/ttyUSB0:/dev/ttyUSB0" +``` +build image: **docker-compose up --build** +start with **docker-compose up --detach** diff --git a/mqttclient/.gitignore b/mqttclient/.gitignore new file mode 100644 index 0000000..1120be9 --- /dev/null +++ b/mqttclient/.gitignore @@ -0,0 +1 @@ +docker-compose.yml diff --git a/mqttclient/fanATserial2mqtt.py b/mqttclient/fanATserial2mqtt.py index 2a068e3..08fa93f 100644 --- a/mqttclient/fanATserial2mqtt.py +++ b/mqttclient/fanATserial2mqtt.py @@ -77,7 +77,7 @@ try: continue except (serial.SerialException): client.publish(mqtt_topic + "exception", "serial reopen") # check which port was really used - time.sleep(1.0) + time.sleep(3.0) try: line = ser.readline() # read a '\n' terminated line @@ -149,7 +149,7 @@ try: else: client.publish(mqtt_topic + "debug", line) # line was invalid and could not be parsed else: - time.sleep(0.2) + time.sleep(0.5) except (KeyboardInterrupt, SystemExit): print("User aborted service ...")