PySwitchbot 0.57.0__tar.gz → 0.58.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.57.0 → pyswitchbot-0.58.0}/PKG-INFO +3 -2
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/PySwitchbot.egg-info/PKG-INFO +3 -2
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/PySwitchbot.egg-info/SOURCES.txt +2 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/setup.py +1 -1
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parser.py +2 -8
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/hub2.py +16 -0
- pyswitchbot-0.58.0/switchbot/const/hub2.py +29 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/tests/test_adv_parser.py +1 -25
- pyswitchbot-0.58.0/tests/test_hub2.py +18 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/LICENSE +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/MANIFEST.in +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/PySwitchbot.egg-info/dependency_links.txt +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/PySwitchbot.egg-info/requires.txt +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/PySwitchbot.egg-info/top_level.txt +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/README.md +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/pyproject.toml +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/setup.cfg +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/__init__.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/__init__.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/blind_tilt.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/bot.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/bulb.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/ceiling_light.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/contact.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/curtain.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/humidifier.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/keypad.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/leak.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/light_strip.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/lock.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/meter.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/motion.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/plug.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/relay_switch.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/adv_parsers/remote.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/api_config.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/const/__init__.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/const/evaporative_humidifier.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/const/lock.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/__init__.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/base_cover.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/base_light.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/blind_tilt.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/bot.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/bulb.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/ceiling_light.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/contact.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/curtain.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/device.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/evaporative_humidifier.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/humidifier.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/keypad.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/light_strip.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/lock.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/meter.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/motion.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/plug.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/devices/relay_switch.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/discovery.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/enum.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/helpers.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/switchbot/models.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/tests/test_base_cover.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/tests/test_blind_tilt.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/tests/test_curtain.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/tests/test_evaporative_humidifier.py +0 -0
- {pyswitchbot-0.57.0 → pyswitchbot-0.58.0}/tests/test_relay_switch.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: PySwitchbot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.58.0
|
|
4
4
|
Summary: A library to communicate with Switchbot
|
|
5
5
|
Home-page: https://github.com/sblibs/pySwitchbot/
|
|
6
6
|
Author: Daniel Hjelseth Hoyer
|
|
@@ -26,6 +26,7 @@ Dynamic: description
|
|
|
26
26
|
Dynamic: description-content-type
|
|
27
27
|
Dynamic: home-page
|
|
28
28
|
Dynamic: license
|
|
29
|
+
Dynamic: license-file
|
|
29
30
|
Dynamic: requires-dist
|
|
30
31
|
Dynamic: requires-python
|
|
31
32
|
Dynamic: summary
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: PySwitchbot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.58.0
|
|
4
4
|
Summary: A library to communicate with Switchbot
|
|
5
5
|
Home-page: https://github.com/sblibs/pySwitchbot/
|
|
6
6
|
Author: Daniel Hjelseth Hoyer
|
|
@@ -26,6 +26,7 @@ Dynamic: description
|
|
|
26
26
|
Dynamic: description-content-type
|
|
27
27
|
Dynamic: home-page
|
|
28
28
|
Dynamic: license
|
|
29
|
+
Dynamic: license-file
|
|
29
30
|
Dynamic: requires-dist
|
|
30
31
|
Dynamic: requires-python
|
|
31
32
|
Dynamic: summary
|
|
@@ -35,6 +35,7 @@ switchbot/adv_parsers/relay_switch.py
|
|
|
35
35
|
switchbot/adv_parsers/remote.py
|
|
36
36
|
switchbot/const/__init__.py
|
|
37
37
|
switchbot/const/evaporative_humidifier.py
|
|
38
|
+
switchbot/const/hub2.py
|
|
38
39
|
switchbot/const/lock.py
|
|
39
40
|
switchbot/devices/__init__.py
|
|
40
41
|
switchbot/devices/base_cover.py
|
|
@@ -60,4 +61,5 @@ tests/test_base_cover.py
|
|
|
60
61
|
tests/test_blind_tilt.py
|
|
61
62
|
tests/test_curtain.py
|
|
62
63
|
tests/test_evaporative_humidifier.py
|
|
64
|
+
tests/test_hub2.py
|
|
63
65
|
tests/test_relay_switch.py
|
|
@@ -41,8 +41,6 @@ SERVICE_DATA_ORDER = (
|
|
|
41
41
|
)
|
|
42
42
|
MFR_DATA_ORDER = (2409, 741, 89)
|
|
43
43
|
|
|
44
|
-
APPLE_MANUFACTURER_ID = 76
|
|
45
|
-
|
|
46
44
|
|
|
47
45
|
class SwitchbotSupportedType(TypedDict):
|
|
48
46
|
"""Supported type of Switchbot."""
|
|
@@ -250,14 +248,10 @@ def parse_advertisement_data(
|
|
|
250
248
|
|
|
251
249
|
_mfr_data = None
|
|
252
250
|
_mfr_id = None
|
|
253
|
-
manufacturer_data = advertisement_data.manufacturer_data
|
|
254
|
-
if APPLE_MANUFACTURER_ID in manufacturer_data:
|
|
255
|
-
return None
|
|
256
|
-
|
|
257
251
|
for mfr_id in MFR_DATA_ORDER:
|
|
258
|
-
if mfr_id in manufacturer_data:
|
|
252
|
+
if mfr_id in advertisement_data.manufacturer_data:
|
|
259
253
|
_mfr_id = mfr_id
|
|
260
|
-
_mfr_data = manufacturer_data[mfr_id]
|
|
254
|
+
_mfr_data = advertisement_data.manufacturer_data[mfr_id]
|
|
261
255
|
break
|
|
262
256
|
|
|
263
257
|
if _mfr_data is None and _service_data is None:
|
|
@@ -4,6 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
|
+
from ..const.hub2 import LIGHT_INTENSITY_MAP
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
def process_wohub2(data: bytes | None, mfr_data: bytes | None) -> dict[str, Any]:
|
|
9
11
|
"""Process woHub2 sensor manufacturer data."""
|
|
@@ -35,6 +37,20 @@ def process_wohub2(data: bytes | None, mfr_data: bytes | None) -> dict[str, Any]
|
|
|
35
37
|
"fahrenheit": bool(temp_data[2] & 0b10000000),
|
|
36
38
|
"humidity": humidity,
|
|
37
39
|
"lightLevel": light_level,
|
|
40
|
+
"illuminance": calculate_light_intensity(light_level),
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
return _wohub2_data
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def calculate_light_intensity(light_level: int) -> int:
|
|
47
|
+
"""
|
|
48
|
+
Convert Hub 2 light level (1-21) to actual light intensity value
|
|
49
|
+
Args:
|
|
50
|
+
light_level: Integer from 1-21
|
|
51
|
+
Returns:
|
|
52
|
+
Corresponding light intensity value or 0 if invalid input
|
|
53
|
+
"""
|
|
54
|
+
if not light_level:
|
|
55
|
+
return 0
|
|
56
|
+
return LIGHT_INTENSITY_MAP.get(max(0, min(light_level, 22)), 0)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Mapping of light levels to lux measurement values for SwitchBot Hub 2.
|
|
3
|
+
|
|
4
|
+
Source: After-sales consultation, line chart data provided by switchbot developers
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
LIGHT_INTENSITY_MAP = {
|
|
8
|
+
1: 0,
|
|
9
|
+
2: 10,
|
|
10
|
+
3: 20,
|
|
11
|
+
4: 30,
|
|
12
|
+
5: 40,
|
|
13
|
+
6: 50,
|
|
14
|
+
7: 60,
|
|
15
|
+
8: 70,
|
|
16
|
+
9: 80,
|
|
17
|
+
10: 90,
|
|
18
|
+
11: 105,
|
|
19
|
+
12: 205,
|
|
20
|
+
13: 317,
|
|
21
|
+
14: 416,
|
|
22
|
+
15: 510,
|
|
23
|
+
16: 610,
|
|
24
|
+
17: 707,
|
|
25
|
+
18: 801,
|
|
26
|
+
19: 897,
|
|
27
|
+
20: 1023,
|
|
28
|
+
21: 1091,
|
|
29
|
+
}
|
|
@@ -947,6 +947,7 @@ def test_wohub2_passive_and_active():
|
|
|
947
947
|
"fahrenheit": False,
|
|
948
948
|
"humidity": 50,
|
|
949
949
|
"lightLevel": 2,
|
|
950
|
+
"illuminance": 10,
|
|
950
951
|
"temp": {"c": 26.7, "f": 80.06},
|
|
951
952
|
"temperature": 26.7,
|
|
952
953
|
},
|
|
@@ -1970,28 +1971,3 @@ def test_remote_passive() -> None:
|
|
|
1970
1971
|
rssi=-97,
|
|
1971
1972
|
active=False,
|
|
1972
1973
|
)
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
def test_parse_advertisement_ignores_devices_with_apple_manufacturer_id():
|
|
1976
|
-
"""Test parse_advertisement_data ignores devices with apple manufacturer id."""
|
|
1977
|
-
ble_device = generate_ble_device("aa:bb:cc:dd:ee:ff", "any")
|
|
1978
|
-
adv_data = generate_advertisement_data(
|
|
1979
|
-
local_name="WoCurtain",
|
|
1980
|
-
manufacturer_data={
|
|
1981
|
-
89: b"\xcc\xf4\xc4\xf9\xacl",
|
|
1982
|
-
2409: b"\xcc\xf4\xc4\xf9\xacl\xe2\x0f\x00\x12\x04",
|
|
1983
|
-
76: b"\x10",
|
|
1984
|
-
},
|
|
1985
|
-
service_data={
|
|
1986
|
-
"00000d00-0000-1000-8000-00805f9b34fb": b"c\xd0Yd\x11\x04",
|
|
1987
|
-
"0000fd3d-0000-1000-8000-00805f9b34fb": b"c\xc0d\x00\x12\x04",
|
|
1988
|
-
},
|
|
1989
|
-
service_uuids=[
|
|
1990
|
-
"00001800-0000-1000-8000-00805f9b34fb",
|
|
1991
|
-
"00001801-0000-1000-8000-00805f9b34fb",
|
|
1992
|
-
"cba20d00-224d-11e6-9fb8-0002a5d5c51b",
|
|
1993
|
-
],
|
|
1994
|
-
rssi=-2,
|
|
1995
|
-
)
|
|
1996
|
-
result = parse_advertisement_data(ble_device, adv_data)
|
|
1997
|
-
assert result is None
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from switchbot.adv_parsers.hub2 import calculate_light_intensity
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_calculate_light_intensity():
|
|
5
|
+
"""Test calculating light intensity from Hub 2 light level."""
|
|
6
|
+
# Test valid inputs
|
|
7
|
+
assert calculate_light_intensity(1) == 0
|
|
8
|
+
assert calculate_light_intensity(2) == 10
|
|
9
|
+
assert calculate_light_intensity(10) == 90
|
|
10
|
+
assert calculate_light_intensity(15) == 510
|
|
11
|
+
assert calculate_light_intensity(21) == 1091
|
|
12
|
+
|
|
13
|
+
# Test invalid inputs
|
|
14
|
+
assert calculate_light_intensity(0) == 0
|
|
15
|
+
assert calculate_light_intensity(22) == 0
|
|
16
|
+
assert calculate_light_intensity(-1) == 0
|
|
17
|
+
assert calculate_light_intensity(3.5) == 0
|
|
18
|
+
assert calculate_light_intensity(None) == 0
|
|
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
|
|
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
|