python-aidot 0.1.1__tar.gz → 0.1.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.1
2
2
  Name: python-aidot
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: aidot control wifi lights
5
5
  Home-page: https://github.com/Aidot-Development-Team/python-aidot
6
6
  Author: aidotdev2024
@@ -21,15 +21,47 @@ class Lan(object):
21
21
  _cct : int
22
22
  _login_uuid = 0
23
23
  _available : bool = False
24
-
24
+
25
25
  _connectAndLogin : bool = False
26
26
  _connecting = False
27
27
  _simpleVersion = ""
28
28
  _colorMode = ""
29
-
29
+
30
+ @property
31
+ def is_on(self) -> bool:
32
+ return self._is_on
33
+
34
+ @property
35
+ def brightness(self) -> int:
36
+ return self._dimming * 255 / 100
37
+
38
+ @property
39
+ def rgdb(self) -> int:
40
+ return self._rgdb
41
+
42
+ @property
43
+ def cct(self) -> int:
44
+ return self._cct
45
+
46
+ @property
47
+ def available(self) -> bool:
48
+ return self._available
49
+
50
+ @property
51
+ def connectAndLogin(self) -> bool:
52
+ return self._connectAndLogin
53
+
54
+ @property
55
+ def connecting(self) -> bool:
56
+ return self._connecting
57
+
58
+ @property
59
+ def colorMode(self) -> str:
60
+ return self._colorMode
61
+
30
62
  def __init__(self,device:dict,user_info:dict) -> None:
31
63
  self.ping_count = 0
32
-
64
+
33
65
  if "id" in user_info:
34
66
  self.user_id = user_info["id"]
35
67
 
@@ -37,7 +69,7 @@ class Lan(object):
37
69
  key_string = device["aesKey"][0]
38
70
  if key_string is not None:
39
71
  self.aes_key = bytearray(16)
40
- key_bytes = key_string.encode()
72
+ key_bytes = key_string.encode()
41
73
  self.aes_key[:len(key_bytes)] = key_bytes
42
74
 
43
75
  if "password" in device:
@@ -67,10 +99,6 @@ class Lan(object):
67
99
  def setUpdateDeviceCb(self,callback):
68
100
  self._updateDeviceCb = callback
69
101
 
70
- @property
71
- def brightness(self) -> int:
72
- return self._dimming * 255 / 100
73
-
74
102
  def printfHex(self,packet):
75
103
  hex_representation = binascii.hexlify(packet).decode()
76
104
 
@@ -80,7 +108,7 @@ class Lan(object):
80
108
 
81
109
  if self.aes_key is not None:
82
110
  send_data = aes_encrypt(message,self.aes_key)
83
- else :
111
+ else :
84
112
  send_data = message
85
113
 
86
114
  bodysize = struct.pack('>i', len(send_data))
@@ -91,7 +119,7 @@ class Lan(object):
91
119
  async def login(self):
92
120
  login_seq = str(int(time.time() * 1000) + self._login_uuid)[-9:]
93
121
  self._login_uuid += 1
94
- timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
122
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
95
123
  message = {
96
124
  "service":"device",
97
125
  "method":"loginReq",
@@ -112,12 +140,12 @@ class Lan(object):
112
140
  data_len = len(data)
113
141
  if(data_len <= 0):
114
142
  return
115
-
143
+
116
144
  magic, msgtype, bodysize = struct.unpack('>HHI', data[:8])
117
145
  encrypted_data = data[8:]
118
146
  if self.aes_key is not None:
119
147
  decrypted_data = aes_decrypt(encrypted_data, self.aes_key)
120
- else :
148
+ else :
121
149
  decrypted_data = encrypted_data
122
150
 
123
151
  json_data = json.loads(decrypted_data)
@@ -127,7 +155,7 @@ class Lan(object):
127
155
 
128
156
  self._available = True
129
157
 
130
- await self.sendAction({},"getDevAttrReq")
158
+ await self.sendAction({},"getDevAttrReq")
131
159
 
132
160
  async def recvData(self):
133
161
  while True:
@@ -140,7 +168,7 @@ class Lan(object):
140
168
  data_len = len(data)
141
169
  if(data_len <= 0):
142
170
  break
143
-
171
+
144
172
  try:
145
173
  magic, msgtype, bodysize = struct.unpack('>HHI', data[:8])
146
174
  encrypted_data = data[8:]
@@ -154,7 +182,7 @@ class Lan(object):
154
182
 
155
183
  if "service" in json_data:
156
184
  if "test" == json_data["service"]:
157
- self.ping_count = 0
185
+ self.ping_count = 0
158
186
 
159
187
  if "payload" in json_data:
160
188
  if "ascNumber" in json_data["payload"]:
@@ -171,10 +199,10 @@ class Lan(object):
171
199
  self._cct = json_data["payload"]["attr"]["CCT"]
172
200
  self._colorMode = "cct"
173
201
  if self._updateDeviceCb:
174
- await self._updateDeviceCb()
202
+ await self._updateDeviceCb()
175
203
 
176
204
  async def ping_task(self):
177
- while True:
205
+ while True:
178
206
  if await self.sendPingAction() == -1 :
179
207
  return
180
208
  await asyncio.sleep(10)
@@ -254,7 +282,7 @@ class Lan(object):
254
282
  _LOGGER.error(f"{self.device_id} send action error {e}")
255
283
  except Exception as e:
256
284
  _LOGGER.error(f"{self.device_id} send action error {e}")
257
-
285
+
258
286
  async def sendPingAction(self):
259
287
  ping = {
260
288
  "service": "test",
@@ -265,9 +293,9 @@ class Lan(object):
265
293
  }
266
294
  try:
267
295
  if self.ping_count >= 2 :
268
- _LOGGER.error(f"Last ping did not return within 20 seconds. device id:{self.device_id}")
269
- await self.reset()
270
- return -1
296
+ _LOGGER.error(f"Last ping did not return within 20 seconds. device id:{self.device_id}")
297
+ await self.reset()
298
+ return -1
271
299
  self.writer.write(self.getSendPacket(json.dumps(ping).encode(),2))
272
300
  await self.writer.drain()
273
301
  self.ping_count += 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-aidot
3
- Version: 0.1.1
3
+ Version: 0.1.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.1.1",
8
+ version="0.1.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