python-aidot 0.3.51__tar.gz → 0.3.52__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-aidot
3
- Version: 0.3.51
3
+ Version: 0.3.52
4
4
  Summary: aidot control wifi lights
5
5
  Home-page: https://github.com/Aidot-Development-Team/python-aidot
6
6
  Author: aidotdev2024
@@ -15,7 +15,7 @@ import hashlib
15
15
  from .exceptions import AidotAuthFailed, AidotUserOrPassIncorrect
16
16
  from .device_client import DeviceClient
17
17
  from .discover import Discover
18
- from .login_const import APP_ID, PUBLIC_KEY_PEM, BASE_URL
18
+ from .login_const import APP_ID, PUBLIC_KEY_PEM, API_URL_TEMPLATE, DEFAULT_REGION
19
19
  from .const import (
20
20
  CONF_ACCESS_TOKEN,
21
21
  CONF_APP_ID,
@@ -58,8 +58,8 @@ def rsa_password_encrypt(message: str) -> str:
58
58
 
59
59
 
60
60
  class AidotClient:
61
- _base_url: str = BASE_URL
62
- _region: str = "us"
61
+ _base_url: str = API_URL_TEMPLATE.format(region=DEFAULT_REGION)
62
+ _region: str = DEFAULT_REGION
63
63
  session: Optional[ClientSession] = None
64
64
  username: str = ""
65
65
  password: str = ""
@@ -77,7 +77,7 @@ class AidotClient:
77
77
  password: str | None = None,
78
78
  token: dict | None = None,
79
79
  ) -> None:
80
- _LOGGER.warning(f"Aidot Client Version: v0.3.51")
80
+ _LOGGER.info("Client Version: v0.3.52")
81
81
  self.session = session
82
82
  self.username = username
83
83
  self.password = password
@@ -87,7 +87,7 @@ class AidotClient:
87
87
  if item["id"] == self.country_code:
88
88
  self.country_name = item["name"]
89
89
  self._region = item["region"].lower()
90
- self._base_url = f"https://prod-{self._region}-api.arnoo.com/v17"
90
+ self._base_url = API_URL_TEMPLATE.format(region=self._region)
91
91
  break
92
92
  if token is not None:
93
93
  self.login_info = token.copy()
@@ -95,7 +95,7 @@ class AidotClient:
95
95
  self.password = token[CONF_PASSWORD]
96
96
  self._region = token[CONF_REGION]
97
97
  self.country_name = token[CONF_COUNTRY]
98
- self._base_url = f"https://prod-{self._region}-api.arnoo.com/v17"
98
+ self._base_url = API_URL_TEMPLATE.format(region=self._region)
99
99
  self.setup_discover()
100
100
  def set_token_fresh_cb(self, callback) -> None:
101
101
  self._token_fresh_cb = callback
@@ -153,7 +153,7 @@ class AidotClient:
153
153
  self.setup_discover()
154
154
  return self.login_info
155
155
  except aiohttp.ClientError as e:
156
- _LOGGER.info(f"async_post_login ClientError {e}")
156
+ _LOGGER.error(f"async_post_login ClientError: {e}")
157
157
  if response_data[CONF_CODE] == ServerErrorCode.USER_PWD_INCORRECT:
158
158
  raise AidotUserOrPassIncorrect
159
159
  raise Exception
@@ -172,12 +172,12 @@ class AidotClient:
172
172
  self.login_info[CONF_ACCESS_TOKEN] = response_data[CONF_ACCESS_TOKEN]
173
173
  if response_data[CONF_REFRESH_TOKEN] is not None:
174
174
  self.login_info[CONF_REFRESH_TOKEN] = response_data[CONF_REFRESH_TOKEN]
175
- _LOGGER.info(f"refresh token {response_data}")
175
+ _LOGGER.debug(f"refresh token: {response_data}")
176
176
  if self._token_fresh_cb:
177
177
  self._token_fresh_cb()
178
178
  return response_data
179
179
  except aiohttp.ClientError as e:
180
- _LOGGER.info(f"async_refresh_token ClientError {e} {response_data}")
180
+ _LOGGER.error(f"async_refresh_token ClientError: {e} {response_data}")
181
181
  if response_data[CONF_CODE] == ServerErrorCode.LOGIN_INVALID:
182
182
  raise AidotAuthFailed
183
183
  return None
@@ -202,7 +202,7 @@ class AidotClient:
202
202
  response.raise_for_status()
203
203
  return response_data
204
204
  except aiohttp.ClientError as e:
205
- _LOGGER.info(f"async_get ClientError {e} {response_data}")
205
+ _LOGGER.error(f"async_get ClientError: {e} {response_data}")
206
206
  code = response_data.get(CONF_CODE)
207
207
  if code == ServerErrorCode.TOKEN_EXPIRED:
208
208
  try:
@@ -300,5 +300,5 @@ class AidotClient:
300
300
 
301
301
  async def async_cleanup(self) -> None:
302
302
  """清理所有资源"""
303
- _LOGGER.info(f"async_cleanup")
303
+ _LOGGER.debug("async_cleanup")
304
304
  await self.async_close()
@@ -101,6 +101,7 @@ SUPPORTED_COUNTRYS = [
101
101
  {"_id": "16-4", "id": "PK", "name": "Pakistan", "ext": "", "region": "JP"},
102
102
  {"_id": "16-5", "id": "PS", "name": "Palestine", "ext": "", "region": "JP"},
103
103
  {"_id": "16-6", "id": "PH", "name": "Philippines", "ext": "", "region": "JP"},
104
+ {"_id": "16-7", "id": "PL", "name": "Poland", "ext": "", "region": "EU"},
104
105
  {"_id": "17-0", "id": "QA", "name": "Qatar", "ext": "", "region": "JP"},
105
106
  {"_id": "18-0", "id": "RO", "name": "Romania", "ext": "", "region": "EU"},
106
107
  {"_id": "18-1", "id": "RU", "name": "Russia", "ext": "", "region": "EU"},
@@ -1,7 +1,10 @@
1
- """Constants for the aidot integration."""
1
+ """Constants for the aidot login."""
2
2
 
3
3
  APP_ID = "1383974540041977857"
4
- BASE_URL = "https://prod-us-api.arnoo.com/v17"
4
+
5
+ # API URL template - use .format(region="us") to construct
6
+ API_URL_TEMPLATE = "https://prod-{region}-api.arnoo.com/v17"
7
+ DEFAULT_REGION = "us"
5
8
 
6
9
  PUBLIC_KEY_PEM = b"""
7
10
  -----BEGIN PUBLIC KEY-----
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-aidot
3
- Version: 0.3.51
3
+ Version: 0.3.52
4
4
  Summary: aidot control wifi lights
5
5
  Home-page: https://github.com/Aidot-Development-Team/python-aidot
6
6
  Author: aidotdev2024
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="python-aidot",
8
- version="0.3.51",
8
+ version="0.3.52",
9
9
  author="aidotdev2024",
10
10
  url='https://github.com/Aidot-Development-Team/python-aidot',
11
11
  description="aidot control wifi lights",
File without changes
File without changes
File without changes