python-aidot 0.3.49__tar.gz → 0.3.50__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.49
3
+ Version: 0.3.50
4
4
  Summary: aidot control wifi lights
5
5
  Home-page: https://github.com/Aidot-Development-Team/python-aidot
6
6
  Author: aidotdev2024
@@ -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.49")
80
+ _LOGGER.warning(f"Aidot Client Version: v0.3.50")
81
81
  self.session = session
82
82
  self.username = username
83
83
  self.password = password
@@ -106,19 +106,19 @@ class AidotClient:
106
106
  def update_password(self, password: str) -> None:
107
107
  self.password = password
108
108
 
109
- def get_terminal_id(self) -> str:
109
+ async def get_terminal_id(self) -> str:
110
110
  file_path = Path.home() / ".aidot_terminal_id"
111
- if file_path.exists():
112
- raw_id = file_path.read_text().strip()
113
- else:
111
+
112
+ def _read_or_create() -> str:
113
+ if file_path.exists():
114
+ return file_path.read_text().strip()
114
115
  node = uuid.getnode()
115
116
  is_random = (node >> 40) & 1
116
-
117
- if is_random:
118
- raw_id = str(uuid.uuid4())
119
- else:
120
- raw_id = format(node, 'x')
117
+ raw_id = str(uuid.uuid4()) if is_random else format(node, "x")
121
118
  file_path.write_text(raw_id)
119
+ return raw_id
120
+
121
+ raw_id = await asyncio.to_thread(_read_or_create)
122
122
  return hashlib.md5(raw_id.encode()).hexdigest()
123
123
 
124
124
  async def async_post_login(self) -> dict[str, Any]:
@@ -126,7 +126,7 @@ class AidotClient:
126
126
  url = f"{self._base_url}/users/loginWithFreeVerification"
127
127
  headers = {CONF_APP_ID: APP_ID, CONF_TERMINAL: "app"}
128
128
  # f"{region}:{self.country_name.strip()}",
129
- terminalId = self.get_terminal_id()
129
+ terminalId = await self.get_terminal_id()
130
130
  if terminalId is None:
131
131
  terminalId = "gvz3gjae10l4zii00t7y0"
132
132
  data = {
@@ -152,9 +152,10 @@ class DeviceClient(object):
152
152
  sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
153
153
  self.seq_num = 1
154
154
  await self.login()
155
- self._connect_and_login = True
155
+ self._connect_and_login = self.status.online
156
156
  except Exception as e:
157
157
  self._connect_and_login = False
158
+ _LOGGER.warning(f"{self._TAG}:connect device error: {e}")
158
159
  finally:
159
160
  self._connecting = False
160
161
 
@@ -257,7 +258,6 @@ class DeviceClient(object):
257
258
  raise
258
259
  except (BrokenPipeError, ConnectionResetError, asyncio.IncompleteReadError) as e:
259
260
  _LOGGER.error(f"{self._TAG}:read status error {e}")
260
- # await self.reset()
261
261
  asyncio.get_running_loop().call_soon(
262
262
  lambda: asyncio.create_task(self.reset())
263
263
  )
@@ -365,7 +365,7 @@ class DeviceClient(object):
365
365
  "srcAddr": "x.xxxxxxx",
366
366
  CONF_PAYLOAD: {},
367
367
  }
368
- # _LOGGER.info(f"{self.device_id} send_ping_action {ping}")
368
+ _LOGGER.info(f"{self.device_id} send_ping_action {ping}")
369
369
  try:
370
370
  if self.ping_count >= 3:
371
371
  _LOGGER.error(
@@ -427,5 +427,5 @@ class DeviceClient(object):
427
427
  # 10, # 10秒后重连
428
428
  # lambda: asyncio.create_task(self.async_login())
429
429
  # )
430
- self._reconnect_handle = loop.call_later(15, self._schedule_reconnect)
430
+ self._reconnect_handle = loop.call_later(60, self._schedule_reconnect)
431
431
  self._login_task = asyncio.create_task(self.async_login())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-aidot
3
- Version: 0.3.49
3
+ Version: 0.3.50
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.49",
8
+ version="0.3.50",
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