mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
[ASUSWRT] Added router port to configurtation
This commit is contained in:
@@ -207,7 +207,7 @@
|
|||||||
"description": [
|
"description": [
|
||||||
{
|
{
|
||||||
"language_code": "en_us",
|
"language_code": "en_us",
|
||||||
"string": "Router ip(do not include <code>http://</code> or <code>https://</code>)."
|
"string": "Router ip(do not include port, <code>http://</code> or <code>https://</code>)."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -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",
|
"function": "password",
|
||||||
"type": {
|
"type": {
|
||||||
|
|||||||
@@ -77,8 +77,13 @@ def get_device_data():
|
|||||||
# Create aiohttp session
|
# Create aiohttp session
|
||||||
session = aiohttp.ClientSession(loop=loop)
|
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
|
router = AsusRouter( # required - both IP and URL supported
|
||||||
hostname=get_setting_value("ASUSWRT_host"), # required
|
hostname=get_setting_value("ASUSWRT_host"), # required
|
||||||
|
port=(None if not port else port), # optional
|
||||||
username=get_setting_value("ASUSWRT_user"), # required
|
username=get_setting_value("ASUSWRT_user"), # required
|
||||||
password=get_setting_value("ASUSWRT_password"), # required
|
password=get_setting_value("ASUSWRT_password"), # required
|
||||||
use_ssl=get_setting_value("ASUSWRT_ssl"), # optional
|
use_ssl=get_setting_value("ASUSWRT_ssl"), # optional
|
||||||
@@ -86,14 +91,9 @@ def get_device_data():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Connect to the router
|
# Connect to the router
|
||||||
|
# Throws an error in case of failure
|
||||||
loop.run_until_complete(router.async_connect())
|
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
|
# Now you can use the router object to call methods
|
||||||
clients = loop.run_until_complete(router.async_get_data(AsusData.CLIENTS))
|
clients = loop.run_until_complete(router.async_get_data(AsusData.CLIENTS))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user