aboutsummaryrefslogtreecommitdiffstats
path: root/tasmotaMQTTClient.py
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2025-12-03 15:07:27 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2025-12-03 15:07:27 +0000
commit1de2a671e7260314708a239f8f27cc9457b8140e (patch)
treea8b201448a8f04813c71fd96492116ecdb6ebb43 /tasmotaMQTTClient.py
parentdd7790dab8d3fbea8f2b58eb4d5aaffc36b3cb09 (diff)
downloadTasmotaCLI-1de2a671e7260314708a239f8f27cc9457b8140e.tar.gz
TasmotaCLI-1de2a671e7260314708a239f8f27cc9457b8140e.zip
Added optionally adding a password for MQTT, allowing noninteractive running in scripts
Diffstat (limited to 'tasmotaMQTTClient.py')
-rw-r--r--tasmotaMQTTClient.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/tasmotaMQTTClient.py b/tasmotaMQTTClient.py
index e8a43b8..07f7fae 100644
--- a/tasmotaMQTTClient.py
+++ b/tasmotaMQTTClient.py
@@ -73,6 +73,11 @@ parser.add_argument(
required = True
)
parser.add_argument(
+ "-p", "--password",
+ type = str,
+ help = "Password to use in scripts. If ran interactively, omit this option otherwise the password will appear in logs"
+)
+parser.add_argument(
"-t", "--toggle",
action = "store_true",
help = "Toggle current power status"
@@ -88,10 +93,8 @@ if __name__ == "__main__":
args = vars(parser.parse_args())
if args["mqtt_host"] == "<docker>":
args["mqtt_host"] = docker_net.get_mqtt_addr()[0]
- if args["user"] is not None:
+ if args["password"] is None:
args["password"] = getpass.getpass("Input password for %s@%s: " % (args["user"], args["mqtt_host"]))
- else:
- args["password"] = None
if args["toggle"]:
client = MQTTClient(args["mqtt_host"], args["friendlyname"], args["user"], args["password"], "TOGGLE")