python-aidot 0.3.0__tar.gz → 0.3.2__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.2
2
2
  Name: python-aidot
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: aidot control wifi lights
5
5
  Home-page: https://github.com/Aidot-Development-Team/python-aidot
6
6
  Author: aidotdev2024
@@ -12,7 +12,7 @@ from .exceptions import AidotOSError
12
12
  _LOGGER = logging.getLogger(__name__)
13
13
 
14
14
  class BroadcastProtocol:
15
- _is_running: bool = True
15
+ _is_closed = False
16
16
  def __init__(self,callback,user_id):
17
17
  self.aes_key = bytearray(32)
18
18
  key_string = "T54uednca587"
@@ -28,6 +28,9 @@ class BroadcastProtocol:
28
28
  sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
29
29
 
30
30
  def send_broadcast(self) -> None:
31
+ if self._is_closed is True:
32
+ _LOGGER.error(f"{self.user_id}:Connection is closed")
33
+ return
31
34
  current_timestamp_milliseconds = int(time.time() * 1000)
32
35
  seq = str(current_timestamp_milliseconds + 1)[-9:]
33
36
  message = {
@@ -44,7 +47,10 @@ class BroadcastProtocol:
44
47
  }
45
48
  }
46
49
  send_data = aes_encrypt(json.dumps(message).encode(),self.aes_key)
47
- self.transport.sendto(send_data, ('255.255.255.255', 6666))
50
+ try:
51
+ self.transport.sendto(send_data, ('255.255.255.255', 6666))
52
+ except Exception as error:
53
+ _LOGGER.error(f"{self.user_id}:Connection lost due to error: {error}")
48
54
 
49
55
  def datagram_received(self, data, addr):
50
56
  data_str = aes_decrypt(data,self.aes_key)
@@ -56,16 +62,21 @@ class BroadcastProtocol:
56
62
  self._discover_cb(devId,{CONF_IPADDRESS : addr[0]})
57
63
 
58
64
  def error_received(self, exc):
59
- _LOGGER.error(f"Error occurred: {exc}")
65
+ _LOGGER.error(f"{self.user_id}:Error occurred: {exc}")
60
66
 
61
67
  def close(self) -> None:
62
- self.transport.close()
68
+ try:
69
+ self.transport.close()
70
+ except Exception as error:
71
+ _LOGGER.error(f"Connection lost due to error: {error}")
72
+
63
73
 
64
74
  def connection_lost(self, exc):
75
+ self._is_closed = True
65
76
  if exc:
66
- _LOGGER.error(f"Connection lost due to error: {exc}")
77
+ _LOGGER.error(f"{self.user_id}:Connection lost due to error: {exc}")
67
78
  else:
68
- _LOGGER.info("Connection closed.")
79
+ _LOGGER.info("{self.user_id}:Connection closed.")
69
80
 
70
81
  class Discover:
71
82
  _login_info: dict[str: Any] = None
@@ -96,5 +107,4 @@ class Discover:
96
107
  def close(self) -> None:
97
108
  if self._broadcast_protocol is not None:
98
109
  self._broadcast_protocol.close()
99
-
100
-
110
+ self._broadcast_protocol.send_broadcast()
@@ -15,7 +15,10 @@ class AidotAuthTokenExpired(AidotError):
15
15
  """Authentication failed because token is invalid or expired."""
16
16
 
17
17
  class AidotAuthFailed(AidotError):
18
- """Authentication failed """
18
+ """Authentication failed"""
19
+
20
+ class AidotUserOrPassIncorrect(AidotError):
21
+ """Authentication failed"""
19
22
 
20
23
  class AidotOSError(Exception):
21
- """Aidot exception."""
24
+ """Aidot exception."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: python-aidot
3
- Version: 0.3.0
3
+ Version: 0.3.2
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.0",
8
+ version="0.3.2",
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
File without changes