violet-poolController-api 0.0.39__tar.gz → 0.0.41__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.
- {violet_poolcontroller_api-0.0.39/violet_poolController_api.egg-info → violet_poolcontroller_api-0.0.41}/PKG-INFO +1 -1
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/pyproject.toml +1 -1
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_api.py +90 -18
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_mock_server.py +16 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41/violet_poolController_api.egg-info}/PKG-INFO +1 -1
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/_api_readings.py +11 -2
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/const_api.py +8 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/const_devices.py +17 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/LICENSE +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/README.md +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/setup.cfg +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_api_smoke.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_circuit_breaker.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_language_policy.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_parsers.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_rate_limiter.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_readings.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_sanitizer.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolController_api.egg-info/SOURCES.txt +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolController_api.egg-info/dependency_links.txt +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolController_api.egg-info/requires.txt +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolController_api.egg-info/top_level.txt +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/__init__.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/_api_dosing.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/_api_mixin.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/_api_model.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/_api_outputs.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/_api_system.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/api.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/circuit_breaker.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/parsers.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/py.typed +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/readings.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/utils_rate_limiter.py +0 -0
- {violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/violet_poolcontroller_api/utils_sanitizer.py +0 -0
|
@@ -34,6 +34,7 @@ from violet_poolcontroller_api.api import (
|
|
|
34
34
|
VioletPoolAPI,
|
|
35
35
|
VioletPoolAPIError,
|
|
36
36
|
VioletSetpointError,
|
|
37
|
+
VioletUnsafeOperationError,
|
|
37
38
|
)
|
|
38
39
|
from violet_poolcontroller_api.circuit_breaker import CircuitBreakerOpenError
|
|
39
40
|
from violet_poolcontroller_api.const_api import (
|
|
@@ -42,6 +43,7 @@ from violet_poolcontroller_api.const_api import (
|
|
|
42
43
|
ERROR_SEVERITY_INFO,
|
|
43
44
|
ERROR_SEVERITY_REMINDER,
|
|
44
45
|
ERROR_SEVERITY_WARNING,
|
|
46
|
+
QUERY_FULL_REFRESH,
|
|
45
47
|
TARGET_PH,
|
|
46
48
|
)
|
|
47
49
|
|
|
@@ -92,7 +94,7 @@ async def test_get_readings_success(
|
|
|
92
94
|
api_client: VioletPoolAPI,
|
|
93
95
|
) -> None:
|
|
94
96
|
"""Test get_readings returns the correct parsed JSON dictionary."""
|
|
95
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
97
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
96
98
|
mock_data = {"PUMPSTATE": "2", "PH": 7.2}
|
|
97
99
|
mock_aioresponse.get(url, payload=mock_data, status=200)
|
|
98
100
|
|
|
@@ -102,6 +104,25 @@ async def test_get_readings_success(
|
|
|
102
104
|
assert dict(result) == mock_data
|
|
103
105
|
|
|
104
106
|
|
|
107
|
+
@pytest.mark.asyncio
|
|
108
|
+
async def test_get_readings_requests_all_feature_flags(
|
|
109
|
+
mock_aioresponse: aioresponses,
|
|
110
|
+
api_client: VioletPoolAPI,
|
|
111
|
+
) -> None:
|
|
112
|
+
"""Plain ``ALL`` omits the computed fields (daily dosing totals, runtime
|
|
113
|
+
strings, priority-state composites) on some firmware states, leaving the
|
|
114
|
+
matching sensors at ``unknown``. get_readings() must therefore always
|
|
115
|
+
ask for ``ALL`` combined with every feature-flag token."""
|
|
116
|
+
url = f"http://192.168.1.100/getReadings?{QUERY_FULL_REFRESH}"
|
|
117
|
+
mock_aioresponse.get(url, payload={"PUMPSTATE": "2"}, status=200)
|
|
118
|
+
|
|
119
|
+
await api_client.get_readings()
|
|
120
|
+
|
|
121
|
+
# aioresponses matches the URL exactly; reaching this point without an
|
|
122
|
+
# unsatisfied-mock error proves the full query string was sent.
|
|
123
|
+
assert mock_aioresponse.requests
|
|
124
|
+
|
|
125
|
+
|
|
105
126
|
@pytest.mark.asyncio
|
|
106
127
|
async def test_get_output_runtimes_success(
|
|
107
128
|
mock_aioresponse: aioresponses,
|
|
@@ -164,7 +185,7 @@ async def test_request_server_error(
|
|
|
164
185
|
api_client: VioletPoolAPI,
|
|
165
186
|
) -> None:
|
|
166
187
|
"""Test that a 500 error raises VioletPoolAPIError after retrying."""
|
|
167
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
188
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
168
189
|
mock_aioresponse.get(url, status=500)
|
|
169
190
|
# the second time it retries
|
|
170
191
|
mock_aioresponse.get(url, status=500)
|
|
@@ -358,7 +379,7 @@ async def test_get_readings_standalone_list_format(
|
|
|
358
379
|
api_client: VioletPoolAPI,
|
|
359
380
|
) -> None:
|
|
360
381
|
"""Test get_readings parses the standalone list format correctly."""
|
|
361
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
382
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
362
383
|
mock_data = {
|
|
363
384
|
"getReadings": [
|
|
364
385
|
{
|
|
@@ -394,7 +415,7 @@ async def test_dosing_standalone_detection_dict_format(
|
|
|
394
415
|
standalone_api_client: VioletPoolAPI,
|
|
395
416
|
) -> None:
|
|
396
417
|
"""Test dosing_standalone is set to False when dict format is received."""
|
|
397
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
418
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
398
419
|
mock_data = {
|
|
399
420
|
"getReadings": {
|
|
400
421
|
"PUMPSTATE": "2",
|
|
@@ -414,7 +435,7 @@ async def test_dosing_standalone_detection_dict_format(
|
|
|
414
435
|
@pytest.mark.asyncio
|
|
415
436
|
async def test_get_hardware_profile(mock_aioresponse, api_client):
|
|
416
437
|
"""Test get_hardware_profile correctly detects components via alive counters."""
|
|
417
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
438
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
418
439
|
|
|
419
440
|
# 1. Base module only (no DOS, EXT)
|
|
420
441
|
mock_aioresponse.get(
|
|
@@ -524,7 +545,7 @@ async def test_module_alive_on_zero_count(mock_aioresponse, api_client):
|
|
|
524
545
|
old code required value > 0, which caused EXT1_* readings to be filtered
|
|
525
546
|
and the relay switch to appear broken right after a restart.
|
|
526
547
|
"""
|
|
527
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
548
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
528
549
|
mock_aioresponse.get(
|
|
529
550
|
url,
|
|
530
551
|
payload={
|
|
@@ -548,7 +569,7 @@ async def test_module_alive_on_zero_count(mock_aioresponse, api_client):
|
|
|
548
569
|
@pytest.mark.asyncio
|
|
549
570
|
async def test_ext1_readings_not_filtered_when_detected(mock_aioresponse, api_client):
|
|
550
571
|
"""EXT1_* readings are included when extension_module_1 is detected."""
|
|
551
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
572
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
552
573
|
mock_aioresponse.get(
|
|
553
574
|
url,
|
|
554
575
|
payload={
|
|
@@ -572,7 +593,7 @@ async def test_ext1_readings_not_filtered_when_detected(mock_aioresponse, api_cl
|
|
|
572
593
|
@pytest.mark.asyncio
|
|
573
594
|
async def test_ext1_readings_filtered_when_not_detected(mock_aioresponse, api_client):
|
|
574
595
|
"""EXT1_* readings are stripped when extension_module_1 key is absent."""
|
|
575
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
596
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
576
597
|
mock_aioresponse.get(
|
|
577
598
|
url,
|
|
578
599
|
payload={
|
|
@@ -594,7 +615,7 @@ async def test_ext1_readings_filtered_when_not_detected(mock_aioresponse, api_cl
|
|
|
594
615
|
@pytest.mark.asyncio
|
|
595
616
|
async def test_get_hardware_profile_standalone_dosing(mock_aioresponse, standalone_api_client):
|
|
596
617
|
"""Test get_hardware_profile with a standalone dosing configuration."""
|
|
597
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
618
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
598
619
|
# Using the standalone list format
|
|
599
620
|
mock_data = {
|
|
600
621
|
"getReadings": [
|
|
@@ -823,6 +844,57 @@ async def test_set_light_color_pulse(
|
|
|
823
844
|
assert result["success"] is True
|
|
824
845
|
|
|
825
846
|
|
|
847
|
+
@pytest.mark.asyncio
|
|
848
|
+
@pytest.mark.parametrize(
|
|
849
|
+
("action", "cover_key"),
|
|
850
|
+
[
|
|
851
|
+
("OPEN", "COVER_OPEN"),
|
|
852
|
+
("CLOSE", "COVER_CLOSE"),
|
|
853
|
+
("STOP", "COVER_STOP"),
|
|
854
|
+
("open", "COVER_OPEN"),
|
|
855
|
+
],
|
|
856
|
+
)
|
|
857
|
+
async def test_set_cover_command_wire_format(
|
|
858
|
+
mock_aioresponse: aioresponses,
|
|
859
|
+
api_client: VioletPoolAPI,
|
|
860
|
+
action: str,
|
|
861
|
+
cover_key: str,
|
|
862
|
+
) -> None:
|
|
863
|
+
"""Cover commands must be the bare function name with no action suffix.
|
|
864
|
+
|
|
865
|
+
The controller answers the generic ``COVER_OPEN,PUSH,0,0`` form with
|
|
866
|
+
"ERROR ... I DON'T KNOW THIS OUTPUT WRONG SPELLING OR NOT SUPPORTED"
|
|
867
|
+
(live hardware, firmware 1.2.5). The exact mock URL doubles as the
|
|
868
|
+
assertion: a parameterised request would find no mock and fail.
|
|
869
|
+
"""
|
|
870
|
+
url = f"http://192.168.1.100/setFunctionManually?{cover_key}"
|
|
871
|
+
mock_aioresponse.get(url, body=f"OK\n{cover_key}", status=200)
|
|
872
|
+
|
|
873
|
+
result = await api_client.set_cover_command(action, acknowledge_unsafe=True)
|
|
874
|
+
|
|
875
|
+
assert result["success"] is True
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
@pytest.mark.asyncio
|
|
879
|
+
async def test_set_cover_command_requires_acknowledgement(
|
|
880
|
+
api_client: VioletPoolAPI,
|
|
881
|
+
) -> None:
|
|
882
|
+
"""Cover movement must stay behind the acknowledge_unsafe gate."""
|
|
883
|
+
with pytest.raises(VioletUnsafeOperationError):
|
|
884
|
+
await api_client.set_cover_command("OPEN")
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
@pytest.mark.asyncio
|
|
888
|
+
async def test_set_cover_command_unknown_action(
|
|
889
|
+
api_client: VioletPoolAPI,
|
|
890
|
+
) -> None:
|
|
891
|
+
"""Unknown cover actions are rejected before any request is sent."""
|
|
892
|
+
with pytest.raises(VioletPoolAPIError) as exc_info:
|
|
893
|
+
await api_client.set_cover_command("HALF", acknowledge_unsafe=True)
|
|
894
|
+
|
|
895
|
+
assert "Unknown cover action" in str(exc_info.value)
|
|
896
|
+
|
|
897
|
+
|
|
826
898
|
@pytest.mark.asyncio
|
|
827
899
|
async def test_trigger_digital_input_rule(
|
|
828
900
|
mock_aioresponse: aioresponses,
|
|
@@ -1874,7 +1946,7 @@ async def test_client_error_fails_fast_without_retry(
|
|
|
1874
1946
|
api_client: VioletPoolAPI,
|
|
1875
1947
|
) -> None:
|
|
1876
1948
|
"""A 4xx response raises immediately instead of being retried."""
|
|
1877
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
1949
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
1878
1950
|
mock_aioresponse.get(url, status=401, body="Unauthorized")
|
|
1879
1951
|
|
|
1880
1952
|
with pytest.raises(VioletPoolAPIError, match="HTTP 401"):
|
|
@@ -1887,7 +1959,7 @@ async def test_client_error_does_not_trip_circuit_breaker(
|
|
|
1887
1959
|
api_client: VioletPoolAPI,
|
|
1888
1960
|
) -> None:
|
|
1889
1961
|
"""Deterministic 4xx errors must not count as circuit breaker failures."""
|
|
1890
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
1962
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
1891
1963
|
threshold = api_client._circuit_breaker.failure_threshold
|
|
1892
1964
|
|
|
1893
1965
|
for _ in range(threshold + 1):
|
|
@@ -1907,7 +1979,7 @@ async def test_empty_get_readings_payload_is_flattened(
|
|
|
1907
1979
|
mock_aioresponse: aioresponses,
|
|
1908
1980
|
api_client: VioletPoolAPI,
|
|
1909
1981
|
) -> None:
|
|
1910
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
1982
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
1911
1983
|
mock_aioresponse.get(url, payload={"getReadings": {}}, status=200)
|
|
1912
1984
|
|
|
1913
1985
|
readings = await api_client.get_readings()
|
|
@@ -1937,7 +2009,7 @@ async def test_basic_auth_uses_authorization_header(
|
|
|
1937
2009
|
mock_aioresponse: aioresponses,
|
|
1938
2010
|
api_client: VioletPoolAPI,
|
|
1939
2011
|
) -> None:
|
|
1940
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
2012
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
1941
2013
|
mock_aioresponse.get(url, payload={}, status=200)
|
|
1942
2014
|
|
|
1943
2015
|
await api_client.get_readings()
|
|
@@ -1953,7 +2025,7 @@ async def test_server_error_still_counts_for_circuit_breaker(
|
|
|
1953
2025
|
api_client: VioletPoolAPI,
|
|
1954
2026
|
) -> None:
|
|
1955
2027
|
"""5xx errors keep counting as circuit breaker failures."""
|
|
1956
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
2028
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
1957
2029
|
mock_aioresponse.get(url, status=500, body="boom", repeat=True)
|
|
1958
2030
|
|
|
1959
2031
|
with pytest.raises(VioletPoolAPIError):
|
|
@@ -1976,7 +2048,7 @@ async def test_rate_limiter_reacquired_on_every_retry(
|
|
|
1976
2048
|
retry loop, so retries fired real HTTP requests without ever going
|
|
1977
2049
|
through the limiter again.
|
|
1978
2050
|
"""
|
|
1979
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
2051
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
1980
2052
|
mock_aioresponse.get(url, status=500, body="boom", repeat=True)
|
|
1981
2053
|
# Backoff sleeps aren't what this test verifies; skip them for speed.
|
|
1982
2054
|
monkeypatch.setattr("violet_poolcontroller_api.api.asyncio.sleep", AsyncMock())
|
|
@@ -2259,7 +2331,7 @@ async def test_reads_are_still_retried(
|
|
|
2259
2331
|
mock_aioresponse: aioresponses,
|
|
2260
2332
|
) -> None:
|
|
2261
2333
|
"""The read path keeps its retries; repeating a read costs nothing."""
|
|
2262
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
2334
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
2263
2335
|
mock_aioresponse.get(url, status=500, body="boom")
|
|
2264
2336
|
mock_aioresponse.get(url, status=500, body="boom")
|
|
2265
2337
|
mock_aioresponse.get(url, payload={"getReadings": {"PUMP": "1"}}, status=200)
|
|
@@ -2282,7 +2354,7 @@ async def test_rate_limit_wait_timeout_fails_instead_of_bypassing(
|
|
|
2282
2354
|
Sending anyway let every caller that waited out the timeout hit the
|
|
2283
2355
|
controller at once, which is the pile-up the limiter exists to prevent.
|
|
2284
2356
|
"""
|
|
2285
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
2357
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
2286
2358
|
mock_aioresponse.get(url, payload={"getReadings": {}}, status=200)
|
|
2287
2359
|
|
|
2288
2360
|
async with aiohttp.ClientSession() as session:
|
|
@@ -2308,7 +2380,7 @@ async def test_html_login_page_does_not_open_the_circuit_breaker(
|
|
|
2308
2380
|
Counting those as transient failures opened the breaker and replaced the
|
|
2309
2381
|
payload error that explains the actual problem.
|
|
2310
2382
|
"""
|
|
2311
|
-
url = "http://192.168.1.100/getReadings?ALL"
|
|
2383
|
+
url = "http://192.168.1.100/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
2312
2384
|
for _ in range(8):
|
|
2313
2385
|
mock_aioresponse.get(url, body="<html>login</html>", status=200)
|
|
2314
2386
|
|
{violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_mock_server.py
RENAMED
|
@@ -8,6 +8,7 @@ from __future__ import annotations
|
|
|
8
8
|
|
|
9
9
|
import asyncio
|
|
10
10
|
import base64
|
|
11
|
+
import json
|
|
11
12
|
import socket
|
|
12
13
|
import subprocess
|
|
13
14
|
import sys
|
|
@@ -89,6 +90,21 @@ async def test_raw_auth() -> None:
|
|
|
89
90
|
assert status == 200, f"Expected 200, got {status}"
|
|
90
91
|
print(f" OK: status={status} body_len={len(body)}")
|
|
91
92
|
|
|
93
|
+
print()
|
|
94
|
+
print("=" * 60)
|
|
95
|
+
print("TEST 1b: ALL plus feature-flag tokens must not filter the payload")
|
|
96
|
+
print("=" * 60)
|
|
97
|
+
status_mixed, body_mixed = await _request(
|
|
98
|
+
f"http://{HOST}:{PORT}/getReadings?ALL,DOSAGE,RUNTIMES,PUMPPRIOSTATE,BACKWASH,SYSTEM"
|
|
99
|
+
)
|
|
100
|
+
assert status_mixed == 200, f"Expected 200, got {status_mixed}"
|
|
101
|
+
# build_readings() re-randomizes sensor values per call, so compare the
|
|
102
|
+
# key set: ALL + tokens must return the same unfiltered key set as ALL.
|
|
103
|
+
keys_all = set(json.loads(body)["getReadings"])
|
|
104
|
+
keys_mixed = set(json.loads(body_mixed)["getReadings"])
|
|
105
|
+
assert keys_mixed == keys_all, "ALL + tokens must not filter any keys"
|
|
106
|
+
print(f" OK: status={status_mixed} keys={len(keys_mixed)} (same as ALL)")
|
|
107
|
+
|
|
92
108
|
print()
|
|
93
109
|
print("=" * 60)
|
|
94
110
|
print("TEST 2: Raw HTTP - /getConfig without credentials -> 401")
|
|
@@ -14,6 +14,7 @@ from .const_api import (
|
|
|
14
14
|
API_GET_WEATHER_DATA,
|
|
15
15
|
API_PRIORITY_LOW,
|
|
16
16
|
API_READINGS,
|
|
17
|
+
QUERY_FULL_REFRESH,
|
|
17
18
|
)
|
|
18
19
|
from .readings import VioletReadings
|
|
19
20
|
|
|
@@ -81,6 +82,14 @@ class ReadingsMixin(APIClientMixin):
|
|
|
81
82
|
to work unchanged. Typed properties (``readings.pump``,
|
|
82
83
|
``readings.ph``, etc.) are available as an additive convenience.
|
|
83
84
|
|
|
85
|
+
The request uses ``ALL`` combined with every feature-flag token
|
|
86
|
+
(``DOSAGE``, ``RUNTIMES``, ``PUMPPRIOSTATE``, ``BACKWASH``,
|
|
87
|
+
``SYSTEM``): plain ``ALL`` omits the computed fields these tokens
|
|
88
|
+
unlock — daily dosing totals, runtime strings, priority-state
|
|
89
|
+
composites, backwash counters, SYSTEM diagnostics — which leaves the
|
|
90
|
+
corresponding sensors at ``unknown`` (firmware ``getReadings.js``,
|
|
91
|
+
observed after a controller restart).
|
|
92
|
+
|
|
84
93
|
Returns:
|
|
85
94
|
A :class:`VioletReadings` instance wrapping all readings.
|
|
86
95
|
|
|
@@ -90,7 +99,7 @@ class ReadingsMixin(APIClientMixin):
|
|
|
90
99
|
"""
|
|
91
100
|
response = await self._request_json_dict(
|
|
92
101
|
API_READINGS,
|
|
93
|
-
query=
|
|
102
|
+
query=QUERY_FULL_REFRESH,
|
|
94
103
|
payload_name="getReadings",
|
|
95
104
|
)
|
|
96
105
|
flat = self._flatten_getreadings_response(response)
|
|
@@ -109,7 +118,7 @@ class ReadingsMixin(APIClientMixin):
|
|
|
109
118
|
"""
|
|
110
119
|
response = await self._request_json_dict(
|
|
111
120
|
API_READINGS,
|
|
112
|
-
query=
|
|
121
|
+
query=QUERY_FULL_REFRESH,
|
|
113
122
|
payload_name="getReadings",
|
|
114
123
|
)
|
|
115
124
|
# Use flat dict directly (VioletReadings wrapping not needed here)
|
|
@@ -109,6 +109,11 @@ LOG_TYPES = frozenset({LOG_TYPE_ACTIONS, LOG_TYPE_SWITCHING, LOG_TYPE_ONEWIRE})
|
|
|
109
109
|
# Mixing ``ALL`` with such prefixes is fine but redundant.
|
|
110
110
|
#
|
|
111
111
|
# Source: includes/getReadings.js (firmware 1.0.9).
|
|
112
|
+
# Feature-flag tokens of the query language above. Plain ``ALL`` omits
|
|
113
|
+
# every field these tokens unlock, so a "give me everything" refresh must
|
|
114
|
+
# always combine ``ALL`` with all of them.
|
|
115
|
+
FEATURE_FLAG_TOKENS = ("DOSAGE", "RUNTIMES", "PUMPPRIOSTATE", "BACKWASH", "SYSTEM")
|
|
116
|
+
|
|
112
117
|
SPECIFIC_READING_GROUPS = (
|
|
113
118
|
"ADC",
|
|
114
119
|
"DOSAGE",
|
|
@@ -125,6 +130,9 @@ SPECIFIC_READING_GROUPS = (
|
|
|
125
130
|
)
|
|
126
131
|
SPECIFIC_FULL_REFRESH_INTERVAL = 10 # Number of updates before a full refresh
|
|
127
132
|
|
|
133
|
+
# Complete-dataset query: base READINGS plus every computed field group.
|
|
134
|
+
QUERY_FULL_REFRESH = ",".join(("ALL", *FEATURE_FLAG_TOKENS))
|
|
135
|
+
|
|
128
136
|
# =============================================================================
|
|
129
137
|
# API ACTIONS
|
|
130
138
|
# =============================================================================
|
|
@@ -210,6 +210,23 @@ DEVICE_PARAMETERS: dict[str, dict[str, Any]] = {
|
|
|
210
210
|
"supports_timer": True,
|
|
211
211
|
"api_template": "REFILL,{action},{duration},0",
|
|
212
212
|
},
|
|
213
|
+
# NOTE: The cover functions are action-less on the wire. The controller
|
|
214
|
+
# accepts only the bare function name (GET /setFunctionManually?COVER_OPEN,
|
|
215
|
+
# docs/HA_ADDON_REFERENCE.md "Cover Control"); the generic
|
|
216
|
+
# "KEY,ACTION,DURATION,VALUE" form is answered with
|
|
217
|
+
# "ERROR ... I DON'T KNOW THIS OUTPUT WRONG SPELLING OR NOT SUPPORTED"
|
|
218
|
+
# (observed on live hardware, firmware 1.2.5). The templates therefore
|
|
219
|
+
# render the key alone - the PUSH action that set_cover_command() passes
|
|
220
|
+
# to set_switch_state() is deliberately not emitted.
|
|
221
|
+
"COVER_OPEN": {
|
|
222
|
+
"api_template": "COVER_OPEN",
|
|
223
|
+
},
|
|
224
|
+
"COVER_CLOSE": {
|
|
225
|
+
"api_template": "COVER_CLOSE",
|
|
226
|
+
},
|
|
227
|
+
"COVER_STOP": {
|
|
228
|
+
"api_template": "COVER_STOP",
|
|
229
|
+
},
|
|
213
230
|
}
|
|
214
231
|
|
|
215
232
|
# Dynamically add extension relays
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_api_smoke.py
RENAMED
|
File without changes
|
{violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_circuit_breaker.py
RENAMED
|
File without changes
|
{violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_language_policy.py
RENAMED
|
File without changes
|
|
File without changes
|
{violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_rate_limiter.py
RENAMED
|
File without changes
|
{violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_readings.py
RENAMED
|
File without changes
|
{violet_poolcontroller_api-0.0.39 → violet_poolcontroller_api-0.0.41}/tests/test_sanitizer.py
RENAMED
|
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
|