wyzeapy 0.5.27__py3-none-any.whl → 0.5.28__py3-none-any.whl

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.
@@ -626,6 +626,25 @@ class BaseService:
626
626
 
627
627
  return response_json
628
628
 
629
+ async def _get_lock_ble_token(self, device: Device) -> Dict[str, Optional[Any]]:
630
+ await self._auth_lib.refresh_if_should()
631
+
632
+ url_path = "/openapi/lock/v1/ble/token"
633
+
634
+ payload = {
635
+ "uuid": device.mac
636
+ }
637
+
638
+ payload = ford_create_payload(self._auth_lib.token.access_token, payload, url_path, "get")
639
+
640
+ url = f"https://yd-saas-toc.wyzecam.com{url_path}"
641
+
642
+ response_json = await self._auth_lib.get(url, params=payload)
643
+
644
+ check_for_errors_lock(self, response_json)
645
+
646
+ return response_json
647
+
629
648
  async def _get_device_info(self, device: Device) -> Dict[Any, Any]:
630
649
  await self._auth_lib.refresh_if_should()
631
650
 
@@ -4,7 +4,9 @@
4
4
  # the license with this file. If not, please write to:
5
5
  # katie@mulliken.net to receive a copy
6
6
  from .base_service import BaseService
7
+ from ..const import FORD_APP_SECRET
7
8
  from ..types import Device, DeviceTypes
9
+ from ..utils import wyze_decrypt_cbc
8
10
 
9
11
 
10
12
  class Lock(Device):
@@ -13,12 +15,19 @@ class Lock(Device):
13
15
  unlocking = False
14
16
  door_open = False
15
17
  trash_mode = False
18
+ ble_id = None
19
+ ble_token = None
16
20
 
17
21
 
18
22
  class LockService(BaseService):
19
23
  async def update(self, lock: Lock):
20
24
  device_info = await self._get_lock_info(lock)
21
25
  lock.raw_dict = device_info["device"]
26
+ if lock.product_model == "YD_BT1":
27
+ ble_token_info = await self._get_lock_ble_token(lock)
28
+ lock.raw_dict["token"] = ble_token_info["token"]
29
+ lock.ble_id = ble_token_info["token"]["id"]
30
+ lock.ble_token = wyze_decrypt_cbc(FORD_APP_SECRET[:16], ble_token_info["token"]["token"])
22
31
 
23
32
  lock.available = lock.raw_dict.get("onoff_line") == 1
24
33
  lock.door_open = lock.raw_dict.get("door_open_status") == 1
wyzeapy/utils.py CHANGED
@@ -4,6 +4,7 @@
4
4
  # the license with this file. If not, please write to:
5
5
  # katie@mulliken.net to receive a copy
6
6
  import base64
7
+ import binascii
7
8
  import hashlib
8
9
  from typing import Dict, Any, List, Optional
9
10
 
@@ -66,6 +67,20 @@ def wyze_decrypt(key, enc):
66
67
  return decrypt_txt
67
68
 
68
69
 
70
+ def wyze_decrypt_cbc(key: str, enc_hex_str: str) -> str:
71
+ key_hash = hashlib.md5(key.encode("utf-8")).digest()
72
+
73
+ iv = b"0123456789ABCDEF"
74
+ cipher = AES.new(key_hash, AES.MODE_CBC, iv)
75
+
76
+ encrypted_bytes = binascii.unhexlify(enc_hex_str)
77
+ decrypted_bytes = cipher.decrypt(encrypted_bytes)
78
+
79
+ # PKCS5Padding
80
+ padding_length = decrypted_bytes[-1]
81
+ return decrypted_bytes[:-padding_length].decode()
82
+
83
+
69
84
  def create_password(password: str) -> str:
70
85
  hex1 = hashlib.md5(password.encode()).hexdigest()
71
86
  hex2 = hashlib.md5(hex1.encode()).hexdigest()
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: wyzeapy
3
- Version: 0.5.27
3
+ Version: 0.5.28
4
4
  Summary: A library for interacting with Wyze devices
5
5
  License: GPL-3.0-only
6
6
  Author: Katie Mulliken
@@ -10,6 +10,7 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
13
14
  Requires-Dist: aiodns (>=3.2.0,<4.0.0)
14
15
  Requires-Dist: aiohttp (>=3.11.12,<4.0.0)
15
16
  Requires-Dist: pycryptodome (>=3.21.0,<4.0.0)
@@ -4,11 +4,11 @@ wyzeapy/crypto.py,sha256=EI9WkKq4jS0nZS5CIEOSYD_9WtM7kEzrhqEg6YdPUIo,1342
4
4
  wyzeapy/exceptions.py,sha256=BVRF7GMMC2T_ZSfGoIVHQsEjVQ3URd5xT6OYqfNxkY0,759
5
5
  wyzeapy/payload_factory.py,sha256=PtnxN9awH4Wh7FPXrGhfHvyGPPYLLZc4XQ2ldZIZZjk,18897
6
6
  wyzeapy/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- wyzeapy/services/base_service.py,sha256=wEn_QFiTJ6-L6bpx3OdBpTU3XnNo-BjKHH4VJ7Bdjzg,28150
7
+ wyzeapy/services/base_service.py,sha256=o50DuLwD3cciTwsUckT1DxwuN7KiXluF4qjhJp3Vq4U,28709
8
8
  wyzeapy/services/bulb_service.py,sha256=n2Pvuunz5d7Iv275vDQjKxByowBDkVoVrztBLyDAOZE,6840
9
9
  wyzeapy/services/camera_service.py,sha256=KBVDwmmSOHCzlXao9PGFKwvhSeGXttMOgOkI-3DpluU,9931
10
10
  wyzeapy/services/hms_service.py,sha256=3Fhqlmk96dm8LFajjW6P40DCIYMudfN3YIDoVIonqGw,2459
11
- wyzeapy/services/lock_service.py,sha256=cQ3A8nuovqPoofVBoo4dnnP-3GAkrf5Kgn0dPJWyhc0,1780
11
+ wyzeapy/services/lock_service.py,sha256=YbZDTReMVSjZpW-FXwjKh385AY7WP2I4mvvo01H5i2E,2220
12
12
  wyzeapy/services/sensor_service.py,sha256=xI--Zr4Dm6DuZrV5pNxBVA1C6rrfhG4T0AFkvXCxVP8,3252
13
13
  wyzeapy/services/switch_service.py,sha256=8LGZ1MloLGEXLVy8PaUwfoEzCXdwefLIyGUc2aJ4yPc,2205
14
14
  wyzeapy/services/thermostat_service.py,sha256=3yJ8Jx7WPROTkiD2868QrfALFR1QB6_JI4LqcMzOOVc,5228
@@ -23,9 +23,9 @@ wyzeapy/tests/test_switch_service.py,sha256=SLoLOiZk0kIqkp36_oaOK8nUvSy585Rc8mm9
23
23
  wyzeapy/tests/test_thermostat_service.py,sha256=XL893tBuEexbcykhfS6ZxFMPuNXuQCpR-Kj2qKnVroo,5443
24
24
  wyzeapy/tests/test_wall_switch_service.py,sha256=NHbCvVrwutS3aahlOyaTWrTerEOdHbO1fgdv86OiPQA,6238
25
25
  wyzeapy/types.py,sha256=gG6V4YOklcJGnkPKp7exPQeCvHOl7Vcz7-iHZ8duKhc,6427
26
- wyzeapy/utils.py,sha256=vxwshLArRvP7g3qpFBdFcXBCM2741ItNSSsfdeHD5GU,4755
26
+ wyzeapy/utils.py,sha256=rxi_ZDSwFMw8c1PtjHxbyoWOzMNToLZPkr9SG9_fg1Y,5202
27
27
  wyzeapy/wyze_auth_lib.py,sha256=ERDuTQiTpbcNH5-Z38dGFTbLynvkejghp_eCYtb7OQQ,13712
28
- wyzeapy-0.5.27.dist-info/LICENSES/GPL-3.0-only.txt,sha256=tqi_Y64slbCqJW7ndGgNe9GPIfRX2nVGb3YQs7FqzE4,34670
29
- wyzeapy-0.5.27.dist-info/METADATA,sha256=58N37dVxn_gBkvOM09iDpKdpRU8wD7xvTRoUmbJxi9g,563
30
- wyzeapy-0.5.27.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
31
- wyzeapy-0.5.27.dist-info/RECORD,,
28
+ wyzeapy-0.5.28.dist-info/LICENSES/GPL-3.0-only.txt,sha256=tqi_Y64slbCqJW7ndGgNe9GPIfRX2nVGb3YQs7FqzE4,34670
29
+ wyzeapy-0.5.28.dist-info/METADATA,sha256=A8IKR3m7LAuwklAoqEzaC1KY-jgBiiqp9xwEHkdVxPA,614
30
+ wyzeapy-0.5.28.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
31
+ wyzeapy-0.5.28.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 2.1.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any