|
@@ -33,7 +33,7 @@ class RouterAPI:
|
|
|
self.host = host
|
|
self.host = host
|
|
|
self.user = user
|
|
self.user = user
|
|
|
self.pwd = pwd
|
|
self.pwd = pwd
|
|
|
- self.session: aiohttp = session
|
|
|
|
|
|
|
+ self.session: aiohttp.ClientSession = session
|
|
|
|
|
|
|
|
async def async_login(self) -> bool:
|
|
async def async_login(self) -> bool:
|
|
|
"""Login and obtain the session cookie"""
|
|
"""Login and obtain the session cookie"""
|
|
@@ -42,14 +42,19 @@ class RouterAPI:
|
|
|
payload['Input_Account'] = self.user
|
|
payload['Input_Account'] = self.user
|
|
|
payload['Input_Passwd'] = base64.b64encode(
|
|
payload['Input_Passwd'] = base64.b64encode(
|
|
|
self.pwd.encode('utf-8')).decode('utf-8')
|
|
self.pwd.encode('utf-8')).decode('utf-8')
|
|
|
|
|
+
|
|
|
|
|
+ _LOGGER.warning(str(payload))
|
|
|
|
|
|
|
|
- response = await self._session.post(
|
|
|
|
|
- f'{API_SCHEMA}://{self.ip}{API_LOGIN_PATH}',
|
|
|
|
|
|
|
+ response = await self.session.post(
|
|
|
|
|
+ f'{API_SCHEMA}://{self.host}{API_LOGIN_PATH}',
|
|
|
json=payload)
|
|
json=payload)
|
|
|
|
|
|
|
|
if response.ok:
|
|
if response.ok:
|
|
|
|
|
+ _LOGGER.warning(await response.text)
|
|
|
|
|
+
|
|
|
try:
|
|
try:
|
|
|
- data = response.json()
|
|
|
|
|
|
|
+ data = await response.json()
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if 'result' in data:
|
|
if 'result' in data:
|
|
|
if data['result'] == VAL_SUCCES:
|
|
if data['result'] == VAL_SUCCES:
|
|
@@ -71,8 +76,8 @@ class RouterAPI:
|
|
|
"""Query an authenticated API endpoint"""
|
|
"""Query an authenticated API endpoint"""
|
|
|
try:
|
|
try:
|
|
|
async with asyncio.timeout(API_TIMEOUT):
|
|
async with asyncio.timeout(API_TIMEOUT):
|
|
|
- response = await self._session.get(
|
|
|
|
|
- f'{API_SCHEMA}://{self.endpoint}{API_BASE_PATH}',
|
|
|
|
|
|
|
+ response = await self.session.get(
|
|
|
|
|
+ f'{API_SCHEMA}://{self.host}{API_BASE_PATH}',
|
|
|
params={'oid': oid})
|
|
params={'oid': oid})
|
|
|
|
|
|
|
|
if response.ok:
|
|
if response.ok:
|