PySwitchbot 0.50.0__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.
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/PKG-INFO +1 -1
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/PySwitchbot.egg-info/PKG-INFO +1 -1
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/setup.py +1 -1
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/meter.py +9 -36
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/tests/test_adv_parser.py +2 -3
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/LICENSE +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/MANIFEST.in +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/PySwitchbot.egg-info/SOURCES.txt +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/PySwitchbot.egg-info/dependency_links.txt +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/PySwitchbot.egg-info/requires.txt +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/PySwitchbot.egg-info/top_level.txt +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/README.md +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/setup.cfg +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/__init__.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parser.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/__init__.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/blind_tilt.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/bot.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/bulb.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/ceiling_light.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/contact.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/curtain.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/hub2.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/humidifier.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/light_strip.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/lock.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/motion.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/adv_parsers/plug.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/api_config.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/const.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/__init__.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/base_cover.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/base_light.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/blind_tilt.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/bot.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/bulb.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/ceiling_light.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/contact.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/curtain.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/device.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/humidifier.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/light_strip.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/lock.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/meter.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/motion.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/devices/plug.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/discovery.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/enum.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/switchbot/models.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/tests/test_base_cover.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/tests/test_blind_tilt.py +0 -0
- {pyswitchbot-0.50.0 → pyswitchbot-0.51.0}/tests/test_curtain.py +0 -0
|
@@ -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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
@@ -1599,9 +1599,6 @@ def test_meter_pro_passive() -> None:
|
|
|
1599
1599
|
rssi=-67,
|
|
1600
1600
|
)
|
|
1601
1601
|
result = parse_advertisement_data(ble_device, adv_data, SwitchbotModel.METER_PRO)
|
|
1602
|
-
import pprint
|
|
1603
|
-
|
|
1604
|
-
pprint.pprint(result)
|
|
1605
1602
|
assert result == SwitchBotAdvertisement(
|
|
1606
1603
|
address="aa:bb:cc:dd:ee:ff",
|
|
1607
1604
|
data={
|
|
@@ -1643,6 +1640,7 @@ def test_meter_pro_c_active() -> None:
|
|
|
1643
1640
|
"humidity": 36,
|
|
1644
1641
|
"temp": {"c": 27.7, "f": 81.86},
|
|
1645
1642
|
"temperature": 27.7,
|
|
1643
|
+
"co2": 725,
|
|
1646
1644
|
},
|
|
1647
1645
|
"isEncrypted": False,
|
|
1648
1646
|
"model": "5",
|
|
@@ -1674,6 +1672,7 @@ def test_meter_pro_c_passive() -> None:
|
|
|
1674
1672
|
"humidity": 36,
|
|
1675
1673
|
"temp": {"c": 27.7, "f": 81.86},
|
|
1676
1674
|
"temperature": 27.7,
|
|
1675
|
+
"co2": 725,
|
|
1677
1676
|
},
|
|
1678
1677
|
"isEncrypted": False,
|
|
1679
1678
|
"model": "5",
|
|
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
|
|
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
|
|
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
|
|
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
|