From 7e8012c1a02b2e9c10f9a76ac36f786d8ba5a24a Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 25 Nov 2021 07:59:32 +1300 Subject: [PATCH] Allow specifying the dashboard bind address (#2787) --- esphome/__main__.py | 6 ++++++ esphome/dashboard/dashboard.py | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index 7c7c22dd1f..2f06a71b5f 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -637,6 +637,12 @@ def parse_args(argv): type=int, default=6052, ) + parser_dashboard.add_argument( + "--address", + help="The address to bind to.", + type=str, + default="0.0.0.0", + ) parser_dashboard.add_argument( "--username", help="The optional username to require for authentication.", diff --git a/esphome/dashboard/dashboard.py b/esphome/dashboard/dashboard.py index 11571ec889..c98047d9e5 100644 --- a/esphome/dashboard/dashboard.py +++ b/esphome/dashboard/dashboard.py @@ -970,16 +970,17 @@ def start_web_server(args): server.add_socket(socket) else: _LOGGER.info( - "Starting dashboard web server on http://0.0.0.0:%s and configuration dir %s...", + "Starting dashboard web server on http://%s:%s and configuration dir %s...", + args.address, args.port, settings.config_dir, ) - app.listen(args.port) + app.listen(args.port, args.address) if args.open_ui: import webbrowser - webbrowser.open(f"localhost:{args.port}") + webbrowser.open(f"http://{args.address}:{args.port}") if settings.status_use_ping: status_thread = PingStatusThread()