diff options
| author | jwansek <eddie.atten.ea29@gmail.com> | 2025-12-03 15:07:27 +0000 |
|---|---|---|
| committer | jwansek <eddie.atten.ea29@gmail.com> | 2025-12-03 15:07:27 +0000 |
| commit | 1de2a671e7260314708a239f8f27cc9457b8140e (patch) | |
| tree | a8b201448a8f04813c71fd96492116ecdb6ebb43 /tasmotaMQTTClient.py | |
| parent | dd7790dab8d3fbea8f2b58eb4d5aaffc36b3cb09 (diff) | |
| download | TasmotaCLI-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.py | 9 |
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") |
