PySwitchbot 0.50.1__tar.gz → 0.51.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 (52) hide show
  1. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/PKG-INFO +1 -1
  2. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/PySwitchbot.egg-info/PKG-INFO +1 -1
  3. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/setup.py +1 -1
  4. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/meter.py +9 -36
  5. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/tests/test_adv_parser.py +2 -0
  6. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/LICENSE +0 -0
  7. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/MANIFEST.in +0 -0
  8. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/PySwitchbot.egg-info/SOURCES.txt +0 -0
  9. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/PySwitchbot.egg-info/dependency_links.txt +0 -0
  10. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/PySwitchbot.egg-info/requires.txt +0 -0
  11. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/PySwitchbot.egg-info/top_level.txt +0 -0
  12. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/README.md +0 -0
  13. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/setup.cfg +0 -0
  14. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/__init__.py +0 -0
  15. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parser.py +0 -0
  16. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/__init__.py +0 -0
  17. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/blind_tilt.py +0 -0
  18. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/bot.py +0 -0
  19. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/bulb.py +0 -0
  20. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/ceiling_light.py +0 -0
  21. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/contact.py +0 -0
  22. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/curtain.py +0 -0
  23. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/hub2.py +0 -0
  24. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/humidifier.py +0 -0
  25. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/light_strip.py +0 -0
  26. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/lock.py +0 -0
  27. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/motion.py +0 -0
  28. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/adv_parsers/plug.py +0 -0
  29. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/api_config.py +0 -0
  30. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/const.py +0 -0
  31. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/__init__.py +0 -0
  32. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/base_cover.py +0 -0
  33. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/base_light.py +0 -0
  34. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/blind_tilt.py +0 -0
  35. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/bot.py +0 -0
  36. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/bulb.py +0 -0
  37. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/ceiling_light.py +0 -0
  38. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/contact.py +0 -0
  39. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/curtain.py +0 -0
  40. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/device.py +0 -0
  41. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/humidifier.py +0 -0
  42. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/light_strip.py +0 -0
  43. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/lock.py +0 -0
  44. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/meter.py +0 -0
  45. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/motion.py +0 -0
  46. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/devices/plug.py +0 -0
  47. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/discovery.py +0 -0
  48. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/enum.py +0 -0
  49. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/switchbot/models.py +0 -0
  50. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/tests/test_base_cover.py +0 -0
  51. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/tests/test_blind_tilt.py +0 -0
  52. {pyswitchbot-0.50.1 → pyswitchbot-0.51.0}/tests/test_curtain.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySwitchbot
3
- Version: 0.50.1
3
+ Version: 0.51.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.50.1
3
+ Version: 0.51.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
@@ -10,7 +10,7 @@ setup(
10
10
  "cryptography>=39.0.0",
11
11
  "pyOpenSSL>=23.0.0",
12
12
  ],
13
- version="0.50.1",
13
+ version="0.51.0",
14
14
  description="A library to communicate with Switchbot",
15
15
  author="Daniel Hjelseth Hoyer",
16
16
  url="https://github.com/Danielhiversen/pySwitchbot/",
@@ -1,13 +1,16 @@
1
1
  """Meter parser."""
2
2
  from __future__ import annotations
3
3
 
4
+ import struct
4
5
  from typing import Any
5
6
 
7
+ CO2_UNPACK = struct.Struct(">H").unpack_from
8
+
6
9
 
7
10
  def process_wosensorth(data: bytes | None, mfr_data: bytes | None) -> dict[str, Any]:
8
11
  """Process woSensorTH/Temp sensor services data."""
9
- temp_data = None
10
- battery = None
12
+ temp_data: bytes | None = None
13
+ battery: bytes | None = None
11
14
 
12
15
  if mfr_data:
13
16
  temp_data = mfr_data[8:11]
@@ -45,38 +48,8 @@ def process_wosensorth(data: bytes | None, mfr_data: bytes | None) -> dict[str,
45
48
 
46
49
  def process_wosensorth_c(data: bytes | None, mfr_data: bytes | None) -> dict[str, Any]:
47
50
  """Process woSensorTH/Temp sensor services data with CO2."""
48
- temp_data = None
49
- battery = None
50
-
51
- if mfr_data:
52
- temp_data = mfr_data[8:11]
53
-
54
- if data:
55
- if not temp_data:
56
- temp_data = data[3:6]
57
- battery = data[2] & 0b01111111
58
-
59
- if not temp_data:
60
- return {}
61
-
62
- _temp_sign = 1 if temp_data[1] & 0b10000000 else -1
63
- _temp_c = _temp_sign * (
64
- (temp_data[1] & 0b01111111) + ((temp_data[0] & 0b00001111) / 10)
65
- )
66
- _temp_f = (_temp_c * 9 / 5) + 32
67
- _temp_f = (_temp_f * 10) / 10
68
- humidity = temp_data[2] & 0b01111111
69
-
70
- if _temp_c == 0 and humidity == 0 and battery == 0:
71
- return {}
72
-
73
- _wosensorth_data = {
74
- # Data should be flat, but we keep the original structure for now
75
- "temp": {"c": _temp_c, "f": _temp_f},
76
- "temperature": _temp_c,
77
- "fahrenheit": bool(temp_data[2] & 0b10000000),
78
- "humidity": humidity,
79
- "battery": battery,
80
- }
81
-
51
+ _wosensorth_data = process_wosensorth(data, mfr_data)
52
+ if _wosensorth_data and mfr_data and len(mfr_data) >= 15:
53
+ co2_data = mfr_data[13:15]
54
+ _wosensorth_data["co2"] = CO2_UNPACK(co2_data)[0]
82
55
  return _wosensorth_data
@@ -1640,6 +1640,7 @@ def test_meter_pro_c_active() -> None:
1640
1640
  "humidity": 36,
1641
1641
  "temp": {"c": 27.7, "f": 81.86},
1642
1642
  "temperature": 27.7,
1643
+ "co2": 725,
1643
1644
  },
1644
1645
  "isEncrypted": False,
1645
1646
  "model": "5",
@@ -1671,6 +1672,7 @@ def test_meter_pro_c_passive() -> None:
1671
1672
  "humidity": 36,
1672
1673
  "temp": {"c": 27.7, "f": 81.86},
1673
1674
  "temperature": 27.7,
1675
+ "co2": 725,
1674
1676
  },
1675
1677
  "isEncrypted": False,
1676
1678
  "model": "5",
File without changes
File without changes
File without changes
File without changes