PySwitchbot 0.57.1__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.1 → pyswitchbot-0.58.0}/PKG-INFO +3 -2
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/PySwitchbot.egg-info/PKG-INFO +3 -2
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/PySwitchbot.egg-info/SOURCES.txt +2 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/setup.py +1 -1
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/hub2.py +16 -0
- pyswitchbot-0.58.0/switchbot/const/hub2.py +29 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/tests/test_adv_parser.py +1 -0
- pyswitchbot-0.58.0/tests/test_hub2.py +18 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/LICENSE +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/MANIFEST.in +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/PySwitchbot.egg-info/dependency_links.txt +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/PySwitchbot.egg-info/requires.txt +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/PySwitchbot.egg-info/top_level.txt +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/README.md +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/pyproject.toml +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/setup.cfg +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/__init__.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parser.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/__init__.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/blind_tilt.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/bot.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/bulb.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/ceiling_light.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/contact.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/curtain.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/humidifier.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/keypad.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/leak.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/light_strip.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/lock.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/meter.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/motion.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/plug.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/relay_switch.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/adv_parsers/remote.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/api_config.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/const/__init__.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/const/evaporative_humidifier.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/const/lock.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/__init__.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/base_cover.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/base_light.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/blind_tilt.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/bot.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/bulb.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/ceiling_light.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/contact.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/curtain.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/device.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/evaporative_humidifier.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/humidifier.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/keypad.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/light_strip.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/lock.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/meter.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/motion.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/plug.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/devices/relay_switch.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/discovery.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/enum.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/helpers.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/switchbot/models.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/tests/test_base_cover.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/tests/test_blind_tilt.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/tests/test_curtain.py +0 -0
- {pyswitchbot-0.57.1 → pyswitchbot-0.58.0}/tests/test_evaporative_humidifier.py +0 -0
- {pyswitchbot-0.57.1 → 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
|
|
@@ -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
|
+
}
|
|
@@ -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
|
|
File without changes
|