havenlighting 0.2.2__tar.gz → 0.2.3__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.
- {havenlighting-0.2.2 → havenlighting-0.2.3}/PKG-INFO +1 -1
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting/__init__.py +1 -1
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting/config.py +7 -1
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting/devices/light.py +2 -2
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting.egg-info/PKG-INFO +1 -1
- {havenlighting-0.2.2 → havenlighting-0.2.3}/pyproject.toml +1 -1
- {havenlighting-0.2.2 → havenlighting-0.2.3}/tests/test_light.py +22 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/README.md +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting/client.py +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting/credentials.py +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting/devices/location.py +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting/exceptions.py +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting/logging.py +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting/models.py +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting.egg-info/SOURCES.txt +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting.egg-info/dependency_links.txt +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting.egg-info/requires.txt +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/havenlighting.egg-info/top_level.txt +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/setup.cfg +0 -0
- {havenlighting-0.2.2 → havenlighting-0.2.3}/tests/test_client.py +0 -0
|
@@ -8,9 +8,15 @@ API_TIMEOUT: Final[int] = 30
|
|
|
8
8
|
# Light States
|
|
9
9
|
LIGHT_STATE: Final[dict] = {
|
|
10
10
|
"OFF": 1,
|
|
11
|
-
"ON": 2
|
|
11
|
+
"ON": 2,
|
|
12
|
+
# Seen live (2026-12-03): ~2s after /Commands/On, once the controller
|
|
13
|
+
# confirms, lightingStatusId moves from 2 to 3 (API `status` still "ON").
|
|
14
|
+
"ON_CONFIRMED": 3,
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
# Every lightingStatusId that means the light is on.
|
|
18
|
+
LIGHT_ON_STATES: Final[frozenset] = frozenset({LIGHT_STATE["ON"], LIGHT_STATE["ON_CONFIRMED"]})
|
|
19
|
+
|
|
14
20
|
# Default Light Parameters (brightness is 0-10 on Haven's scale)
|
|
15
21
|
LIGHT_PARAMS: Final[dict] = {
|
|
16
22
|
"BRIGHTNESS": 10,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Dict, Any
|
|
2
2
|
import logging
|
|
3
3
|
from ..models import LightData
|
|
4
|
-
from ..config import LIGHT_STATE, LIGHT_PARAMS
|
|
4
|
+
from ..config import LIGHT_STATE, LIGHT_ON_STATES, LIGHT_PARAMS
|
|
5
5
|
from ..credentials import Credentials
|
|
6
6
|
from ..exceptions import ApiError
|
|
7
7
|
|
|
@@ -33,7 +33,7 @@ class Light:
|
|
|
33
33
|
|
|
34
34
|
@property
|
|
35
35
|
def is_on(self) -> bool:
|
|
36
|
-
return self._data.status
|
|
36
|
+
return self._data.status in LIGHT_ON_STATES
|
|
37
37
|
|
|
38
38
|
def turn_on(self) -> None:
|
|
39
39
|
"""Turn the light on."""
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "havenlighting"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.3"
|
|
8
8
|
description = "Python client for Haven Lighting API"
|
|
9
9
|
authors = [{name = "Mickey Schwab", email = "mickeyschwab@gmail.com"}]
|
|
10
10
|
license = {file = "LICENSE"}
|
|
@@ -56,3 +56,25 @@ def test_turn_on_command_failure_raises(light):
|
|
|
56
56
|
light.turn_on()
|
|
57
57
|
|
|
58
58
|
assert not light.is_on
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _make_light(mocker, **fields):
|
|
62
|
+
data = {"lightId": 456, "name": "Test Light", **fields}
|
|
63
|
+
return Light(mocker.Mock(spec=Credentials), location_id=123, light_id=456, data=data)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_controller_confirmed_on_is_on(mocker):
|
|
67
|
+
# Live capture 2026-12-03: ~2s after /Commands/On, once the controller
|
|
68
|
+
# confirms, the API reports lightingStatusId 3 (status "ON"), not 2.
|
|
69
|
+
light = _make_light(mocker, lightingStatusId=3, status="ON")
|
|
70
|
+
assert light.is_on
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.mark.parametrize("status_id,status_text,expected", [
|
|
74
|
+
(1, "OFF", False),
|
|
75
|
+
(2, "ON", True),
|
|
76
|
+
(3, "ON", True),
|
|
77
|
+
])
|
|
78
|
+
def test_is_on_from_api_status(mocker, status_id, status_text, expected):
|
|
79
|
+
light = _make_light(mocker, lightingStatusId=status_id, status=status_text)
|
|
80
|
+
assert light.is_on is expected
|
|
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
|