python-aidot 0.3.42__tar.gz → 0.3.44__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.44}/PKG-INFO +1 -1
- {python_aidot-0.3.42 → python_aidot-0.3.44}/aidot/client.py +14 -6
- {python_aidot-0.3.42 → python_aidot-0.3.44}/aidot/const.py +5 -2
- {python_aidot-0.3.42 → python_aidot-0.3.44}/aidot/device_client.py +29 -13
- {python_aidot-0.3.42 → python_aidot-0.3.44}/python_aidot.egg-info/PKG-INFO +1 -1
- {python_aidot-0.3.42 → python_aidot-0.3.44}/setup.py +1 -1
- {python_aidot-0.3.42 → python_aidot-0.3.44}/LICENSE +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/README.md +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/aidot/__init__.py +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/aidot/aes_utils.py +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/aidot/discover.py +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/aidot/exceptions.py +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/aidot/login_const.py +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/python_aidot.egg-info/SOURCES.txt +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/python_aidot.egg-info/dependency_links.txt +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/python_aidot.egg-info/requires.txt +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/python_aidot.egg-info/top_level.txt +0 -0
- {python_aidot-0.3.42 → python_aidot-0.3.44}/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
|
|
@@ -88,6 +92,7 @@ class AidotClient:
|
|
|
88
92
|
self.password = token[CONF_PASSWORD]
|
|
89
93
|
self._region = token[CONF_REGION]
|
|
90
94
|
self.country_name = token[CONF_COUNTRY]
|
|
95
|
+
self._base_url = f"https://prod-{self._region}-api.arnoo.com/v17"
|
|
91
96
|
|
|
92
97
|
def set_token_fresh_cb(self, callback) -> None:
|
|
93
98
|
self._token_fresh_cb = callback
|
|
@@ -102,8 +107,9 @@ class AidotClient:
|
|
|
102
107
|
"""Login the user input allows us to connect."""
|
|
103
108
|
url = f"{self._base_url}/users/loginWithFreeVerification"
|
|
104
109
|
headers = {CONF_APP_ID: APP_ID, CONF_TERMINAL: "app"}
|
|
110
|
+
# f"{region}:{self.country_name.strip()}",
|
|
105
111
|
data = {
|
|
106
|
-
"countryKey": "region:
|
|
112
|
+
"countryKey": f"region:{self.country_name.strip()}",
|
|
107
113
|
"username": self.username,
|
|
108
114
|
"password": rsa_password_encrypt(self.password),
|
|
109
115
|
"terminalId": "gvz3gjae10l4zii00t7y0",
|
|
@@ -146,7 +152,7 @@ class AidotClient:
|
|
|
146
152
|
self._token_fresh_cb()
|
|
147
153
|
return response_data
|
|
148
154
|
except aiohttp.ClientError as e:
|
|
149
|
-
_LOGGER.info(f"async_refresh_token ClientError {e}")
|
|
155
|
+
_LOGGER.info(f"async_refresh_token ClientError {e} {response_data}")
|
|
150
156
|
if response_data[CONF_CODE] == ServerErrorCode.LOGIN_INVALID:
|
|
151
157
|
raise AidotAuthFailed
|
|
152
158
|
return None
|
|
@@ -171,7 +177,7 @@ class AidotClient:
|
|
|
171
177
|
response.raise_for_status()
|
|
172
178
|
return response_data
|
|
173
179
|
except aiohttp.ClientError as e:
|
|
174
|
-
_LOGGER.info(f"async_get ClientError {e}")
|
|
180
|
+
_LOGGER.info(f"async_get ClientError {e} {response_data}")
|
|
175
181
|
code = response_data.get(CONF_CODE)
|
|
176
182
|
if code == ServerErrorCode.TOKEN_EXPIRED:
|
|
177
183
|
try:
|
|
@@ -206,6 +212,8 @@ class AidotClient:
|
|
|
206
212
|
try:
|
|
207
213
|
houses = await self.async_get_houses()
|
|
208
214
|
for house in houses:
|
|
215
|
+
if house.get(CONF_IS_OWNER) is False:
|
|
216
|
+
continue
|
|
209
217
|
# get device_list
|
|
210
218
|
device_list = await self.async_get_devices(house[CONF_ID])
|
|
211
219
|
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
|