python-aidot 0.3.42__tar.gz → 0.3.43__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.
- {python_aidot-0.3.42 → python_aidot-0.3.43}/PKG-INFO +1 -1
- {python_aidot-0.3.42 → python_aidot-0.3.43}/aidot/client.py +11 -4
- {python_aidot-0.3.42 → python_aidot-0.3.43}/aidot/const.py +5 -2
- {python_aidot-0.3.42 → python_aidot-0.3.43}/aidot/device_client.py +29 -13
- {python_aidot-0.3.42 → python_aidot-0.3.43}/python_aidot.egg-info/PKG-INFO +1 -1
- {python_aidot-0.3.42 → python_aidot-0.3.43}/setup.py +1 -1
- {python_aidot-0.3.42 → python_aidot-0.3.43}/LICENSE +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/README.md +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/aidot/__init__.py +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/aidot/aes_utils.py +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/aidot/discover.py +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/aidot/exceptions.py +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/aidot/login_const.py +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/python_aidot.egg-info/SOURCES.txt +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/python_aidot.egg-info/dependency_links.txt +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/python_aidot.egg-info/requires.txt +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/python_aidot.egg-info/top_level.txt +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.43}/setup.cfg +0 -0
|
@@ -32,6 +32,8 @@ from .const import (
|
|
|
32
32
|
CONF_USERNAME,
|
|
33
33
|
DEFAULT_COUNTRY_NAME,
|
|
34
34
|
SUPPORTED_COUNTRYS,
|
|
35
|
+
DEFAULT_COUNTRY_CODE,
|
|
36
|
+
CONF_IS_OWNER,
|
|
35
37
|
ServerErrorCode,
|
|
36
38
|
)
|
|
37
39
|
|
|
@@ -60,6 +62,7 @@ class AidotClient:
|
|
|
60
62
|
username: str = ""
|
|
61
63
|
password: str = ""
|
|
62
64
|
country_name: str = DEFAULT_COUNTRY_NAME
|
|
65
|
+
country_code: str = DEFAULT_COUNTRY_CODE
|
|
63
66
|
login_info: dict[str, Any] = {}
|
|
64
67
|
_device_clients: dict[str, DeviceClient]
|
|
65
68
|
_discover: Discover = None
|
|
@@ -67,18 +70,19 @@ class AidotClient:
|
|
|
67
70
|
def __init__(
|
|
68
71
|
self,
|
|
69
72
|
session: Optional[ClientSession],
|
|
70
|
-
|
|
73
|
+
country_code: str | None = None,
|
|
71
74
|
username: str | None = None,
|
|
72
75
|
password: str | None = None,
|
|
73
76
|
token: dict | None = None,
|
|
74
77
|
) -> None:
|
|
75
78
|
self.session = session
|
|
76
|
-
self.country_name = country_name
|
|
77
79
|
self.username = username
|
|
78
80
|
self.password = password
|
|
81
|
+
self.country_code = country_code
|
|
79
82
|
self._device_clients = {}
|
|
80
83
|
for item in SUPPORTED_COUNTRYS:
|
|
81
|
-
if item["
|
|
84
|
+
if item["id"] == self.country_code:
|
|
85
|
+
self.country_name = item["name"]
|
|
82
86
|
self._region = item["region"].lower()
|
|
83
87
|
self._base_url = f"https://prod-{self._region}-api.arnoo.com/v17"
|
|
84
88
|
break
|
|
@@ -102,8 +106,9 @@ class AidotClient:
|
|
|
102
106
|
"""Login the user input allows us to connect."""
|
|
103
107
|
url = f"{self._base_url}/users/loginWithFreeVerification"
|
|
104
108
|
headers = {CONF_APP_ID: APP_ID, CONF_TERMINAL: "app"}
|
|
109
|
+
# f"{region}:{self.country_name.strip()}",
|
|
105
110
|
data = {
|
|
106
|
-
"countryKey": "region:
|
|
111
|
+
"countryKey": f"region:{self.country_name.strip()}",
|
|
107
112
|
"username": self.username,
|
|
108
113
|
"password": rsa_password_encrypt(self.password),
|
|
109
114
|
"terminalId": "gvz3gjae10l4zii00t7y0",
|
|
@@ -206,6 +211,8 @@ class AidotClient:
|
|
|
206
211
|
try:
|
|
207
212
|
houses = await self.async_get_houses()
|
|
208
213
|
for house in houses:
|
|
214
|
+
if house.get(CONF_IS_OWNER) is False:
|
|
215
|
+
continue
|
|
209
216
|
# get device_list
|
|
210
217
|
device_list = await self.async_get_devices(house[CONF_ID])
|
|
211
218
|
if device_list:
|
|
@@ -111,7 +111,7 @@ SUPPORTED_COUNTRYS = [
|
|
|
111
111
|
{"_id": "19-4", "id": "SR", "name": "Suriname", "ext": "", "region": "US"},
|
|
112
112
|
{"_id": "19-5", "id": "SE", "name": "Sweden", "ext": "", "region": "EU"},
|
|
113
113
|
{"_id": "19-6", "id": "SK", "name": "Slovakia", "ext": "", "region": "EU"},
|
|
114
|
-
{"_id": "19-7", "id": "RS
|
|
114
|
+
{"_id": "19-7", "id": "RS", "name": "Serbia", "ext": "", "region": "EU"},
|
|
115
115
|
{
|
|
116
116
|
"_id": "19-8",
|
|
117
117
|
"id": "KN",
|
|
@@ -161,9 +161,10 @@ SUPPORTED_COUNTRYS = [
|
|
|
161
161
|
{"_id": "22-2", "id": "VN", "name": "Vietnam", "ext": "", "region": "JP"},
|
|
162
162
|
{"_id": "23-0", "id": "YE", "name": "Yemen", "ext": "", "region": "JP"},
|
|
163
163
|
]
|
|
164
|
-
|
|
164
|
+
SUPPORTED_COUNTRY_CODES = [item["id"] for item in SUPPORTED_COUNTRYS]
|
|
165
165
|
SUPPORTED_COUNTRY_NAMES = [item["name"] for item in SUPPORTED_COUNTRYS]
|
|
166
166
|
DEFAULT_COUNTRY_NAME = "United States"
|
|
167
|
+
DEFAULT_COUNTRY_CODE = "US"
|
|
167
168
|
CONF_APP_ID = "Appid"
|
|
168
169
|
CONF_TERMINAL = "Terminal"
|
|
169
170
|
CONF_LOGIN_RESPONSE = "login_response"
|
|
@@ -203,6 +204,8 @@ CONF_ON_OFF = "OnOff"
|
|
|
203
204
|
CONF_DIMMING = "Dimming"
|
|
204
205
|
CONF_RGBW = "RGBW"
|
|
205
206
|
CONF_CCT = "CCT"
|
|
207
|
+
CONF_ACK = "ack"
|
|
208
|
+
CONF_IS_OWNER = "isOwner"
|
|
206
209
|
|
|
207
210
|
|
|
208
211
|
class Identity(StrEnum):
|
|
@@ -33,6 +33,8 @@ from .const import (
|
|
|
33
33
|
CONF_PROPERTIES,
|
|
34
34
|
CONF_RGBW,
|
|
35
35
|
CONF_SERVICE_MODULES,
|
|
36
|
+
CONF_ACK,
|
|
37
|
+
CONF_CODE,
|
|
36
38
|
Identity,
|
|
37
39
|
)
|
|
38
40
|
|
|
@@ -203,21 +205,34 @@ class DeviceClient(object):
|
|
|
203
205
|
data_len = len(data)
|
|
204
206
|
if data_len <= 0:
|
|
205
207
|
return
|
|
208
|
+
|
|
209
|
+
try:
|
|
210
|
+
magic, msgtype, bodysize = struct.unpack(">HHI", data[:8])
|
|
211
|
+
encrypted_data = data[8:]
|
|
212
|
+
if self.aes_key is not None:
|
|
213
|
+
decrypted_data = aes_decrypt(encrypted_data, self.aes_key)
|
|
214
|
+
else:
|
|
215
|
+
decrypted_data = encrypted_data
|
|
216
|
+
|
|
217
|
+
json_data = json.loads(decrypted_data)
|
|
218
|
+
code = json_data[CONF_ACK][CONF_CODE]
|
|
219
|
+
if code != 200:
|
|
220
|
+
# 登录失败
|
|
221
|
+
_LOGGER.error(f"{self.device_id} login error, code: {code}")
|
|
222
|
+
await self.reset()
|
|
223
|
+
return
|
|
206
224
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
225
|
+
self.ascNumber = json_data[CONF_PAYLOAD][CONF_ASCNUMBER]
|
|
226
|
+
self.ascNumber += 1
|
|
227
|
+
self.status.online = True
|
|
228
|
+
asyncio.get_running_loop().create_task(self.reveive_data())
|
|
229
|
+
_LOGGER.info(f"connect device success: {self._ip_address}")
|
|
230
|
+
await self.send_action({}, "getDevAttrReq")
|
|
231
|
+
except Exception as e:
|
|
232
|
+
_LOGGER.error(f"connect device error : {e}")
|
|
233
|
+
return
|
|
215
234
|
|
|
216
|
-
|
|
217
|
-
self.ascNumber += 1
|
|
218
|
-
self.status.online = True
|
|
219
|
-
asyncio.get_running_loop().create_task(self.reveive_data())
|
|
220
|
-
await self.send_action({}, "getDevAttrReq")
|
|
235
|
+
|
|
221
236
|
|
|
222
237
|
async def reveive_data(self) -> None:
|
|
223
238
|
while True:
|
|
@@ -243,6 +258,7 @@ class DeviceClient(object):
|
|
|
243
258
|
json_data = json.loads(decrypted_data)
|
|
244
259
|
except Exception as e:
|
|
245
260
|
_LOGGER.error(f"recv json error : {e}")
|
|
261
|
+
continue
|
|
246
262
|
|
|
247
263
|
if "service" in json_data:
|
|
248
264
|
if "test" == json_data["service"]:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|