From 9c2f7ebe90fe43ceac017868a40f1cedf4aac7eb Mon Sep 17 00:00:00 2001 From: Evan Richardson Date: Sun, 2 Sep 2018 23:50:06 -0700 Subject: [PATCH] Added Keepalive, MQTT user and MQTT password options --- Docker/src/conf/broker.py | 10 +++++----- README.md | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Docker/src/conf/broker.py b/Docker/src/conf/broker.py index e98be06..d6c2b7c 100644 --- a/Docker/src/conf/broker.py +++ b/Docker/src/conf/broker.py @@ -5,20 +5,20 @@ import os # for regular and 8883 for SSL. # #=========================================================================== -host = os.getenv('MQTT_BROKER_IP', '192.168.1.18') -port = os.getenv('MQTT_BROKER_PORT', 31333) +host = os.getenv('MQTT_BROKER_IP', '192.168.1.20') +port = os.getenv('MQTT_BROKER_PORT', 1883) # Keep alive time in seconds. Client sends a ping if no other message # is sent in this interval. -keepAlive = 60 +keepAlive = os.getenv('KEEPALIVE', 60) #=========================================================================== # # User name and password (strings) for broker log in. # #=========================================================================== -user = None -password = None +user = os.getenv('MQTT_USER', None) +password = os.getenv('MQTT_PASS', None) #=========================================================================== # diff --git a/README.md b/README.md index 9362d4b..f2f5537 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,21 @@ I have only ported this into a dockerfile, All Original code (with one minor mod Original Readme as follows from creator, Ted Drain. You can view the original repo this is based on here: https://github.com/TD22057/T-Home +You can run this with the following: + +``` +docker run --name py-eagle-mqtt -d -e "MQTT_BROKER_IP=" -e "MQTT_BROKER_PORT=" evanrich/py-eagle/mqtt +``` +MQTT_BROKER_IP = your broker's IP address. Defaults to 192.168.1.20 (my local k8s node) +MQTT_BROKER_PORT = your broker's port #. Defaults to 1883 (used in my k8s) + +Optionally, you can add the following: + +"KEEPALVE=" Sets the keepalive for MQTT, defaults to 60 seconds if not specificed +"MQTT_USER=" Sets the MQTT user, if using authentication. Defaults to "None". Don't specify if not using authentication. +"MQTT_PASS=" Sets the MQTT pasword if using authentication. Defaults to "None". Don't specify if not using authentication. + + snippet from my MQTT Broker showing container connecting and dissconnecting when I start/stop it: ``` {"pid":1,"hostname":"mqtt-867c776494-6rc57","name":"mosca","level":30,"time":1535955884767,"msg":"client connected","client":"","v":1}