PySwitchbot 0.37.6__tar.gz → 0.39.0__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.
Files changed (46) hide show
  1. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/PKG-INFO +1 -1
  2. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/PySwitchbot.egg-info/PKG-INFO +1 -1
  3. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/README.md +21 -1
  4. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/setup.py +1 -1
  5. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parser.py +6 -1
  6. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/blind_tilt.py +1 -1
  7. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/lock.py +1 -0
  8. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/meter.py +5 -2
  9. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/const.py +1 -0
  10. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/blind_tilt.py +5 -1
  11. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/lock.py +12 -1
  12. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/discovery.py +2 -1
  13. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/LICENSE +0 -0
  14. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/MANIFEST.in +0 -0
  15. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/PySwitchbot.egg-info/SOURCES.txt +0 -0
  16. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/PySwitchbot.egg-info/dependency_links.txt +0 -0
  17. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/PySwitchbot.egg-info/requires.txt +0 -0
  18. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/PySwitchbot.egg-info/top_level.txt +0 -0
  19. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/setup.cfg +0 -0
  20. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/__init__.py +0 -0
  21. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/__init__.py +0 -0
  22. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/bot.py +0 -0
  23. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/bulb.py +0 -0
  24. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/ceiling_light.py +0 -0
  25. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/contact.py +0 -0
  26. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/curtain.py +0 -0
  27. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/humidifier.py +0 -0
  28. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/light_strip.py +0 -0
  29. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/motion.py +0 -0
  30. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/adv_parsers/plug.py +0 -0
  31. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/api_config.py +0 -0
  32. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/__init__.py +0 -0
  33. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/base_light.py +0 -0
  34. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/bot.py +0 -0
  35. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/bulb.py +0 -0
  36. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/ceiling_light.py +0 -0
  37. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/contact.py +0 -0
  38. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/curtain.py +0 -0
  39. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/device.py +0 -0
  40. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/humidifier.py +0 -0
  41. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/light_strip.py +0 -0
  42. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/meter.py +0 -0
  43. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/motion.py +0 -0
  44. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/devices/plug.py +0 -0
  45. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/enum.py +0 -0
  46. {PySwitchbot-0.37.6 → PySwitchbot-0.39.0}/switchbot/models.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySwitchbot
3
- Version: 0.37.6
3
+ Version: 0.39.0
4
4
  Summary: A library to communicate with Switchbot
5
5
  Home-page: https://github.com/Danielhiversen/pySwitchbot/
6
6
  Author: Daniel Hjelseth Hoyer
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySwitchbot
3
- Version: 0.37.6
3
+ Version: 0.39.0
4
4
  Summary: A library to communicate with Switchbot
5
5
  Home-page: https://github.com/Danielhiversen/pySwitchbot/
6
6
  Author: Daniel Hjelseth Hoyer
@@ -6,9 +6,29 @@ Using the script `scripts/get_encryption_key.py` you can manually obtain locks e
6
6
 
7
7
  Usage:
8
8
  ```shell
9
- python3 get_encryption_key.py MAC USERNAME
9
+ $ python3 get_encryption_key.py MAC USERNAME
10
+ Key ID: xx
11
+ Encryption key: xxxxxxxxxxxxxxxx
10
12
  ```
13
+
11
14
  Where `MAC` is MAC address of the lock and `USERNAME` is your SwitchBot account username, after that script will ask for your password.
12
15
  If authentication succeeds then script should output your key id and encryption key.
13
16
 
17
+ Examples:
18
+
19
+ * WoLock
20
+
21
+ ```python
22
+ import asyncio
23
+ from switchbot.discovery import GetSwitchbotDevices
24
+ from switchbot.devices import lock
25
+
14
26
 
27
+ async def main():
28
+ wolock = await GetSwitchbotDevices().get_locks()
29
+ await lock.SwitchbotLock(wolock['32C0F607-18B8-xxxx-xxxx-xxxxxxxxxx'].device, "key-id", "encryption-key").get_lock_status()
30
+
31
+
32
+ asyncio.run(main())
33
+
34
+ ```
@@ -12,7 +12,7 @@ setup(
12
12
  "boto3>=1.20.24",
13
13
  "requests>=2.28.1",
14
14
  ],
15
- version="0.37.6",
15
+ version="0.39.0",
16
16
  description="A library to communicate with Switchbot",
17
17
  author="Daniel Hjelseth Hoyer",
18
18
  url="https://github.com/Danielhiversen/pySwitchbot/",
@@ -77,6 +77,12 @@ SUPPORTED_TYPES: dict[str, SwitchbotSupportedType] = {
77
77
  "func": process_wocurtain,
78
78
  "manufacturer_id": 2409,
79
79
  },
80
+ "w": {
81
+ "modelName": SwitchbotModel.IO_METER,
82
+ "modelFriendlyName": "Indoor/Outdoor Meter",
83
+ "func": process_wosensorth,
84
+ "manufacturer_id": 2409,
85
+ },
80
86
  "i": {
81
87
  "modelName": SwitchbotModel.METER,
82
88
  "modelFriendlyName": "Meter Plus",
@@ -93,7 +99,6 @@ SUPPORTED_TYPES: dict[str, SwitchbotSupportedType] = {
93
99
  "modelName": SwitchbotModel.PLUG_MINI,
94
100
  "modelFriendlyName": "Plug Mini",
95
101
  "func": process_woplugmini,
96
- "manufacturer_data_length": 12,
97
102
  "manufacturer_id": 2409,
98
103
  },
99
104
  "j": {
@@ -23,5 +23,5 @@ def process_woblindtilt(
23
23
  "inMotion": _in_motion,
24
24
  "tilt": (100 - _tilt) if reverse else _tilt,
25
25
  "lightLevel": _light_level,
26
- "sequence_number": device_data[0]
26
+ "sequence_number": device_data[0],
27
27
  }
@@ -27,4 +27,5 @@ def process_wolock(data: bytes | None, mfr_data: bytes | None) -> dict[str, bool
27
27
  "unclosed_alarm": bool(mfr_data[8] & 0b00100000),
28
28
  "unlocked_alarm": bool(mfr_data[8] & 0b00010000),
29
29
  "auto_lock_paused": bool(mfr_data[8] & 0b00000010),
30
+ "night_latch": bool(mfr_data[9] & 0b00000001),
30
31
  }
@@ -6,12 +6,15 @@ from typing import Any
6
6
 
7
7
  def process_wosensorth(data: bytes | None, mfr_data: bytes | None) -> dict[str, Any]:
8
8
  """Process woSensorTH/Temp sensor services data."""
9
+ temp_data = None
10
+ battery = None
11
+
9
12
  if mfr_data:
10
13
  temp_data = mfr_data[8:11]
11
- battery = None
12
14
 
13
15
  if data:
14
- temp_data = data[3:6]
16
+ if not temp_data:
17
+ temp_data = data[3:6]
15
18
  battery = data[2] & 0b01111111
16
19
 
17
20
  if not temp_data:
@@ -34,6 +34,7 @@ class SwitchbotModel(StrEnum):
34
34
  CONTACT_SENSOR = "WoContact"
35
35
  LIGHT_STRIP = "WoStrip"
36
36
  METER = "WoSensorTH"
37
+ IO_METER = "WoIOSensorTH"
37
38
  MOTION_SENSOR = "WoPresence"
38
39
  COLOR_BULB = "WoBulb"
39
40
  CEILING_LIGHT = "WoCeiling"
@@ -4,7 +4,11 @@ from __future__ import annotations
4
4
  import logging
5
5
  from typing import Any
6
6
 
7
- from switchbot.devices.device import REQ_HEADER, update_after_operation, SwitchbotSequenceDevice
7
+ from switchbot.devices.device import (
8
+ REQ_HEADER,
9
+ SwitchbotSequenceDevice,
10
+ update_after_operation,
11
+ )
8
12
 
9
13
  from .curtain import CURTAIN_EXT_SUM_KEY, SwitchbotCurtain
10
14
 
@@ -26,6 +26,7 @@ COMMAND_HEADER = "57"
26
26
  COMMAND_GET_CK_IV = f"{COMMAND_HEADER}0f2103"
27
27
  COMMAND_LOCK_INFO = f"{COMMAND_HEADER}0f4f8101"
28
28
  COMMAND_UNLOCK = f"{COMMAND_HEADER}0f4e01011080"
29
+ COMMAND_UNLOCK_WITHOUT_UNLATCH = f"{COMMAND_HEADER}0f4e010110a0"
29
30
  COMMAND_LOCK = f"{COMMAND_HEADER}0f4e01011000"
30
31
  COMMAND_ENABLE_NOTIFICATIONS = f"{COMMAND_HEADER}0e01001e00008101"
31
32
  COMMAND_DISABLE_NOTIFICATIONS = f"{COMMAND_HEADER}0e00"
@@ -164,11 +165,17 @@ class SwitchbotLock(SwitchbotDevice):
164
165
  )
165
166
 
166
167
  async def unlock(self) -> bool:
167
- """Send unlock command."""
168
+ """Send unlock command. If unlatch feature is enabled in EU firmware, also unlatches door"""
168
169
  return await self._lock_unlock(
169
170
  COMMAND_UNLOCK, {LockStatus.UNLOCKED, LockStatus.UNLOCKING}
170
171
  )
171
172
 
173
+ async def unlock_without_unlatch(self) -> bool:
174
+ """Send unlock command. This command will not unlatch the door."""
175
+ return await self._lock_unlock(
176
+ COMMAND_UNLOCK_WITHOUT_UNLATCH, {LockStatus.UNLOCKED, LockStatus.UNLOCKING, LockStatus.NOT_FULLY_LOCKED}
177
+ )
178
+
172
179
  def _parse_basic_data(self, basic_data: bytes) -> dict[str, Any]:
173
180
  """Parse basic data from lock."""
174
181
  return {
@@ -239,6 +246,10 @@ class SwitchbotLock(SwitchbotDevice):
239
246
  """Return True if auto lock is paused."""
240
247
  return self._get_adv_value("auto_lock_paused")
241
248
 
249
+ def is_night_latch_enabled(self) -> bool:
250
+ """Return True if Night Latch is enabled on EU firmware."""
251
+ return self._get_adv_value("night_latch")
252
+
242
253
  async def _get_lock_info(self) -> bytes | None:
243
254
  """Return lock info of device."""
244
255
  _data = await self._send_command(key=COMMAND_LOCK_INFO, retry=self._retry_count)
@@ -103,7 +103,8 @@ class GetSwitchbotDevices:
103
103
  """Return all WoSensorTH/Temp sensor devices with services data."""
104
104
  base_meters = await self._get_devices_by_model("T")
105
105
  plus_meters = await self._get_devices_by_model("i")
106
- return {**base_meters, **plus_meters}
106
+ io_meters = await self._get_devices_by_model("w")
107
+ return {**base_meters, **plus_meters, **io_meters}
107
108
 
108
109
  async def get_contactsensors(self) -> dict[str, SwitchBotAdvertisement]:
109
110
  """Return all WoContact/Contact sensor devices with services data."""
File without changes
File without changes
File without changes