diff --git a/front/plugins/asuswrt_import/config.json b/front/plugins/asuswrt_import/config.json index f25d08df..ce41832f 100755 --- a/front/plugins/asuswrt_import/config.json +++ b/front/plugins/asuswrt_import/config.json @@ -207,7 +207,7 @@ "description": [ { "language_code": "en_us", - "string": "Router ip(do not include http:// or https://)." + "string": "Router ip(do not include port, http:// or https://)." } ] }, @@ -242,6 +242,37 @@ } ] }, + { + "function": "port", + "type": { + "dataType": "string", + "elements": [ + { + "elementType": "input", + "elementOptions": [], + "transformers": [] + } + ] + }, + "default_value": "", + "options": [], + "localized": [ + "name", + "description" + ], + "name": [ + { + "language_code": "en_us", + "string": "Router port" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Router port. Leave empty for default." + } + ] + }, { "function": "password", "type": { diff --git a/front/plugins/asuswrt_import/script.py b/front/plugins/asuswrt_import/script.py index c0b7f3a3..2b2ddb79 100755 --- a/front/plugins/asuswrt_import/script.py +++ b/front/plugins/asuswrt_import/script.py @@ -77,8 +77,13 @@ def get_device_data(): # Create aiohttp session session = aiohttp.ClientSession(loop=loop) + port = get_setting_value("ASUSWRT_port").strip() + + mylog("verbose", [f"[{pluginName}] Connecting to the Router..."]) + router = AsusRouter( # required - both IP and URL supported hostname=get_setting_value("ASUSWRT_host"), # required + port=(None if not port else port), # optional username=get_setting_value("ASUSWRT_user"), # required password=get_setting_value("ASUSWRT_password"), # required use_ssl=get_setting_value("ASUSWRT_ssl"), # optional @@ -86,14 +91,9 @@ def get_device_data(): ) # Connect to the router + # Throws an error in case of failure loop.run_until_complete(router.async_connect()) - if router.connected: - mylog("verbose", [f"[{pluginName}] logged in successfully."]) - else: - mylog("error", [f"[{pluginName}] failed to login."]) - return [] - # Now you can use the router object to call methods clients = loop.run_until_complete(router.async_get_data(AsusData.CLIENTS))