python-hilo 2026.11.2__tar.gz → 2026.11.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.
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.github/workflows/release-drafter.yml +1 -1
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.github/workflows/tests.yaml +2 -2
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/PKG-INFO +1 -1
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/api.py +19 -2
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/const.py +1 -1
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/device/graphql_value_mapper.py +15 -10
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/devices.py +6 -8
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/graphql.py +53 -55
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyproject.toml +1 -1
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/tests/test_api_auth.py +36 -1
- python_hilo-2026.11.3/tests/test_graphql.py +240 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/tests/test_graphql_value_mapper.py +65 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/uv.lock +23 -23
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.bandit.yaml +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.devcontainer/devcontainer-lock.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.devcontainer/devcontainer.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.editorconfig +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.gitattributes +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.github/ISSUE_TEMPLATE/issue.md +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.github/dependabot.yml +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.github/labels.yml +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.github/release-drafter.yml +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.github/workflows/labeler.yml +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.gitignore +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/.pre-commit-config.yaml +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/AGENTS.md +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/LICENSE +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/README.md +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/README.md +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/graphql/onAnyDeviceUpdated-cee.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/graphql/onAnyDeviceUpdated-meter.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/graphql/onAnyDeviceUpdated-tstat.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/postman/hilo-prod.postman_environment.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/postman/hilo.postman_collection.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/rest/location_weather.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/rest/season_events_ch_2025.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/rest/season_events_ch_2026_empty.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/rest/season_events_hilo_2024.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/rest/seasons_summary.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/ChallengeAdded.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/EventAdded.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/EventCHConsumptionUpdatedValuesReceived-during-event.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/EventCHConsumptionUpdatedValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/EventCHDetailsInitialValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/EventCHDetailsUpdatedValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/EventFlexConsumptionUpdatedValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/EventFlexDetailsInitialValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/EventFlexDetailsUpdatedValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/legacy-pre-2025/ChallengeAdded.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/legacy-pre-2025/ChallengeConsumptionUpdatedValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/legacy-pre-2025/ChallengeDetailsInitialValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/legacy-pre-2025/ChallengeListInitialValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/legacy-pre-2025/ChallengeListUpdatedValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/devicehub/DeviceListInitialValuesReceived.json +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/__init__.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/auth.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/device/__init__.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/device/climate.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/device/light.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/device/sensor.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/device/switch.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/event.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/exceptions.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/oauth2helper.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/signalr.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/util/__init__.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/pyhilo/util/state.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/tests/__init__.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/tests/test_climate.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/tests/test_device.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/tests/test_signalr.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/tests/test_util.py +0 -0
- {python_hilo-2026.11.2 → python_hilo-2026.11.3}/tests/test_util_state.py +0 -0
|
@@ -24,7 +24,7 @@ jobs:
|
|
|
24
24
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
|
25
25
|
|
|
26
26
|
- name: Install uv
|
|
27
|
-
uses: astral-sh/setup-uv@v10.
|
|
27
|
+
uses: astral-sh/setup-uv@v10.4.0
|
|
28
28
|
|
|
29
29
|
- name: Install dependencies
|
|
30
30
|
run: uv sync --group dev
|
|
@@ -51,7 +51,7 @@ jobs:
|
|
|
51
51
|
python-version: ${{ matrix.python-version }}
|
|
52
52
|
|
|
53
53
|
- name: Install uv
|
|
54
|
-
uses: astral-sh/setup-uv@v10.
|
|
54
|
+
uses: astral-sh/setup-uv@v10.4.0
|
|
55
55
|
|
|
56
56
|
- name: Install dependencies
|
|
57
57
|
run: uv sync --python ${{ matrix.python-version }} --group test
|
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import base64
|
|
5
|
+
from collections.abc import Mapping
|
|
5
6
|
from datetime import datetime, timedelta
|
|
6
7
|
import json
|
|
7
8
|
import random
|
|
@@ -48,6 +49,20 @@ from pyhilo.exceptions import InvalidCredentialsError, RequestError
|
|
|
48
49
|
from pyhilo.signalr import SignalRHub, SignalRManager
|
|
49
50
|
from pyhilo.util.state import AndroidDeviceDict, StateDict, get_state, set_state
|
|
50
51
|
|
|
52
|
+
_TRACE_REDACTED_KEYS = frozenset(
|
|
53
|
+
{"authorization", "ocp-apim-subscription-key", "accesstoken"}
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _redact_trace(values: object) -> object:
|
|
58
|
+
"""Mask credentials so users can share trace logs when reporting issues."""
|
|
59
|
+
if not isinstance(values, Mapping):
|
|
60
|
+
return values
|
|
61
|
+
return {
|
|
62
|
+
key: "***" if str(key).lower() in _TRACE_REDACTED_KEYS else value
|
|
63
|
+
for key, value in values.items()
|
|
64
|
+
}
|
|
65
|
+
|
|
51
66
|
|
|
52
67
|
class API:
|
|
53
68
|
"""An API object to interact with the Hilo cloud.
|
|
@@ -288,7 +303,7 @@ class API:
|
|
|
288
303
|
data: dict[str, Any] = {}
|
|
289
304
|
url = parse.urljoin(f"https://{host}", endpoint)
|
|
290
305
|
if self.log_traces:
|
|
291
|
-
LOG.debug("[TRACE] Headers: %s", kwargs["headers"])
|
|
306
|
+
LOG.debug("[TRACE] Headers: %s", _redact_trace(kwargs["headers"]))
|
|
292
307
|
LOG.debug("[TRACE] Async request: %s %s", method, url)
|
|
293
308
|
|
|
294
309
|
async with self.session.request(method, url, **kwargs) as resp:
|
|
@@ -302,7 +317,9 @@ class API:
|
|
|
302
317
|
else:
|
|
303
318
|
data = {"message": await resp.text()}
|
|
304
319
|
if self.log_traces:
|
|
305
|
-
LOG.debug(
|
|
320
|
+
LOG.debug(
|
|
321
|
+
"[TRACE] Data received from /%s: %s", endpoint, _redact_trace(data)
|
|
322
|
+
)
|
|
306
323
|
resp.raise_for_status()
|
|
307
324
|
return data
|
|
308
325
|
|
|
@@ -11,7 +11,7 @@ INSTANCE_ID: Final = str(uuid.uuid4())[24:]
|
|
|
11
11
|
LOG: Final = logging.getLogger(__package__)
|
|
12
12
|
DEFAULT_STATE_FILE: Final = "hilo_state.yaml"
|
|
13
13
|
REQUEST_RETRY: Final = 9
|
|
14
|
-
PYHILO_VERSION: Final = "2026.11.
|
|
14
|
+
PYHILO_VERSION: Final = "2026.11.03"
|
|
15
15
|
# TODO: Find a way to keep previous line in sync with pyproject.toml automatically
|
|
16
16
|
|
|
17
17
|
CONTENT_TYPE_FORM: Final = "application/x-www-form-urlencoded"
|
|
@@ -32,10 +32,17 @@ class GraphqlValueMapper:
|
|
|
32
32
|
self, values: Dict[str, Any]
|
|
33
33
|
) -> list[Dict[str, Any]]:
|
|
34
34
|
readings: list[Dict[str, Any]] = []
|
|
35
|
-
for device in values
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
for device in values["devices"]:
|
|
36
|
+
# Unmigrated SignalR devices appear as BasicDevice stubs with null status.
|
|
37
|
+
if device.get("__typename") == "BasicDevice":
|
|
38
|
+
continue
|
|
39
|
+
readings.extend(self._map_basic_device(device))
|
|
40
|
+
if device.get("__typename") == "Gateway":
|
|
41
|
+
readings.append(
|
|
42
|
+
self.build_attribute(
|
|
43
|
+
device["hiloId"], "onlineStatus", device["connectionStatus"]
|
|
44
|
+
)
|
|
45
|
+
)
|
|
39
46
|
return readings
|
|
40
47
|
|
|
41
48
|
def _map_devices_values(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
|
|
@@ -97,21 +104,19 @@ class GraphqlValueMapper:
|
|
|
97
104
|
attributes = []
|
|
98
105
|
attributes.append(
|
|
99
106
|
self.build_attribute(
|
|
100
|
-
device["hiloId"], "
|
|
107
|
+
device["hiloId"], "onlineStatus", device["connectionStatus"]
|
|
101
108
|
)
|
|
102
109
|
)
|
|
103
110
|
attributes.append(
|
|
104
111
|
self.build_attribute(
|
|
105
|
-
device["hiloId"], "
|
|
112
|
+
device["hiloId"], "LastStatusTime", device["lastConnectionTime"]
|
|
106
113
|
)
|
|
107
114
|
)
|
|
108
115
|
attributes.append(
|
|
109
116
|
self.build_attribute(
|
|
110
|
-
device["hiloId"],
|
|
111
|
-
"Disconnected",
|
|
112
|
-
device["connectionStatus"] == "DISCONNECTED",
|
|
117
|
+
device["hiloId"], "Version", device["controllerSoftwareVersion"]
|
|
113
118
|
)
|
|
114
|
-
)
|
|
119
|
+
)
|
|
115
120
|
attributes.append(
|
|
116
121
|
self.build_attribute(
|
|
117
122
|
device["hiloId"],
|
|
@@ -58,20 +58,16 @@ class Devices:
|
|
|
58
58
|
device_identifier: Union[int, str] = reading.device_id
|
|
59
59
|
if device_identifier == 0:
|
|
60
60
|
device_identifier = reading.hilo_id
|
|
61
|
-
device
|
|
62
|
-
# If device_id was 0 and hilo_id lookup failed, this is likely
|
|
63
|
-
# a gateway reading that arrives before GatewayValuesReceived
|
|
64
|
-
# assigns the real ID. Fall back to the gateway device.
|
|
65
|
-
if device is None and reading.device_id == 0:
|
|
66
|
-
device = next((d for d in self.devices if d.type == "Gateway"), None)
|
|
67
|
-
if device:
|
|
61
|
+
if device := self.find_device(device_identifier):
|
|
68
62
|
device.update_readings(reading)
|
|
69
63
|
LOG.debug("%s Received %s", device, reading)
|
|
70
64
|
if device not in updated_devices:
|
|
71
65
|
updated_devices.append(device)
|
|
72
66
|
else:
|
|
73
67
|
LOG.warning(
|
|
74
|
-
|
|
68
|
+
"Unable to find device %s for reading %s",
|
|
69
|
+
device_identifier,
|
|
70
|
+
reading,
|
|
75
71
|
)
|
|
76
72
|
return updated_devices
|
|
77
73
|
|
|
@@ -79,6 +75,8 @@ class Devices:
|
|
|
79
75
|
"""Makes sure the devices received have an identifier, this means some need to be hardcoded
|
|
80
76
|
like the unknown power meter.
|
|
81
77
|
"""
|
|
78
|
+
if not device_identifier:
|
|
79
|
+
return None
|
|
82
80
|
if isinstance(device_identifier, int):
|
|
83
81
|
return next((d for d in self.devices if d.id == device_identifier), None)
|
|
84
82
|
return next((d for d in self.devices if d.hilo_id == device_identifier), None)
|
|
@@ -286,6 +286,9 @@ class GraphQlHelper:
|
|
|
286
286
|
status
|
|
287
287
|
device {
|
|
288
288
|
... on Gateway {
|
|
289
|
+
deviceType
|
|
290
|
+
hiloId
|
|
291
|
+
physicalAddress
|
|
289
292
|
connectionStatus
|
|
290
293
|
controllerSoftwareVersion
|
|
291
294
|
lastConnectionTime
|
|
@@ -516,33 +519,21 @@ class GraphQlHelper:
|
|
|
516
519
|
}
|
|
517
520
|
}"""
|
|
518
521
|
|
|
519
|
-
SUBSCRIPTION_LOCATION_UPDATED: str = """subscription onAnyLocationUpdated($locationHiloId: String!){
|
|
522
|
+
SUBSCRIPTION_LOCATION_UPDATED: str = """subscription onAnyLocationUpdated($locationHiloId: String!) {
|
|
520
523
|
onAnyLocationUpdated(locationHiloId: $locationHiloId) {
|
|
521
|
-
locationHiloId
|
|
522
|
-
deviceType
|
|
523
524
|
transmissionTime
|
|
524
525
|
operationId
|
|
525
526
|
location {
|
|
526
|
-
|
|
527
|
+
devices {
|
|
528
|
+
__typename
|
|
527
529
|
hiloId
|
|
528
|
-
|
|
529
|
-
deviceType
|
|
530
|
-
hiloId
|
|
531
|
-
physicalAddress
|
|
532
|
-
connectionStatus
|
|
533
|
-
... on BasicChargeController {
|
|
534
|
-
connectionStatus
|
|
535
|
-
}
|
|
536
|
-
... on LowVoltageThermostat {
|
|
537
|
-
connectionStatus
|
|
538
|
-
}
|
|
539
|
-
}
|
|
530
|
+
connectionStatus
|
|
540
531
|
}
|
|
541
532
|
}
|
|
542
533
|
}
|
|
543
534
|
}"""
|
|
544
535
|
|
|
545
|
-
async def call_get_location_query(self, location_hilo_id: str) ->
|
|
536
|
+
async def call_get_location_query(self, location_hilo_id: str) -> list[str]:
|
|
546
537
|
"""This functions calls the digital-twin and requests location id"""
|
|
547
538
|
access_token = await self._get_access_token()
|
|
548
539
|
url = f"https://{PLATFORM_HOST}/api/digital-twin/v3/graphql"
|
|
@@ -568,7 +559,7 @@ class GraphQlHelper:
|
|
|
568
559
|
response_json = response.json()
|
|
569
560
|
except Exception as e:
|
|
570
561
|
LOG.error("Error parsing response: %s", e)
|
|
571
|
-
return
|
|
562
|
+
return []
|
|
572
563
|
|
|
573
564
|
if "errors" in response_json:
|
|
574
565
|
for error in response_json["errors"]:
|
|
@@ -582,12 +573,12 @@ class GraphQlHelper:
|
|
|
582
573
|
response_json = response.json()
|
|
583
574
|
except Exception as e:
|
|
584
575
|
LOG.error("Error parsing response on retry: %s", e)
|
|
585
|
-
return
|
|
576
|
+
return []
|
|
586
577
|
break
|
|
587
578
|
|
|
588
579
|
if "errors" in response_json:
|
|
589
580
|
LOG.error("GraphQL errors: %s", response_json["errors"])
|
|
590
|
-
return
|
|
581
|
+
return []
|
|
591
582
|
|
|
592
583
|
if "data" in response_json:
|
|
593
584
|
devices = (
|
|
@@ -600,7 +591,9 @@ class GraphQlHelper:
|
|
|
600
591
|
"Gateway devices in getLocation response: %s",
|
|
601
592
|
json.dumps(gateways, indent=2),
|
|
602
593
|
)
|
|
603
|
-
self._handle_query_result(response_json["data"])
|
|
594
|
+
return self._handle_query_result(response_json["data"])
|
|
595
|
+
|
|
596
|
+
return []
|
|
604
597
|
|
|
605
598
|
async def subscribe_to_device_updated(
|
|
606
599
|
self,
|
|
@@ -650,7 +643,7 @@ class GraphQlHelper:
|
|
|
650
643
|
def _handle_sse_message(
|
|
651
644
|
self,
|
|
652
645
|
data: Dict[str, Any],
|
|
653
|
-
handler: Callable[[Dict[str, Any]], str],
|
|
646
|
+
handler: Callable[[Dict[str, Any]], list[str]],
|
|
654
647
|
callback: Optional[Callable[[str], None]],
|
|
655
648
|
) -> tuple:
|
|
656
649
|
"""Dispatch a parsed SSE message. Returns (retry_apq, had_success)."""
|
|
@@ -663,16 +656,17 @@ class GraphQlHelper:
|
|
|
663
656
|
return False, False
|
|
664
657
|
if "data" in data:
|
|
665
658
|
LOG.debug("Received subscription result %s", data["data"])
|
|
666
|
-
|
|
659
|
+
hilo_ids = handler(data["data"])
|
|
667
660
|
if callback:
|
|
668
|
-
|
|
661
|
+
for hilo_id in hilo_ids:
|
|
662
|
+
callback(hilo_id)
|
|
669
663
|
return False, True
|
|
670
664
|
return False, False
|
|
671
665
|
|
|
672
666
|
async def _drain_sse_events(
|
|
673
667
|
self,
|
|
674
668
|
event_source: Any,
|
|
675
|
-
handler: Callable[[Dict[str, Any]], str],
|
|
669
|
+
handler: Callable[[Dict[str, Any]], list[str]],
|
|
676
670
|
callback: Optional[Callable[[str], None]],
|
|
677
671
|
) -> tuple:
|
|
678
672
|
"""Read events until the stream closes. Returns (retry_apq, had_success)."""
|
|
@@ -707,7 +701,7 @@ class GraphQlHelper:
|
|
|
707
701
|
url: str,
|
|
708
702
|
headers: Dict[str, str],
|
|
709
703
|
payload: Dict[str, Any],
|
|
710
|
-
handler: Callable[[Dict[str, Any]], str],
|
|
704
|
+
handler: Callable[[Dict[str, Any]], list[str]],
|
|
711
705
|
callback: Optional[Callable[[str], None]],
|
|
712
706
|
) -> tuple:
|
|
713
707
|
"""Open one SSE connection and drain it. Returns (retry_apq, had_success)."""
|
|
@@ -723,7 +717,7 @@ class GraphQlHelper:
|
|
|
723
717
|
self,
|
|
724
718
|
query: str,
|
|
725
719
|
variables: Dict[str, Any],
|
|
726
|
-
handler: Callable[[Dict[str, Any]], str],
|
|
720
|
+
handler: Callable[[Dict[str, Any]], list[str]],
|
|
727
721
|
callback: Optional[Callable[[str], None]] = None,
|
|
728
722
|
location_hilo_id: Optional[str] = None,
|
|
729
723
|
) -> None:
|
|
@@ -752,6 +746,7 @@ class GraphQlHelper:
|
|
|
752
746
|
"SSE connection closed by server. Reconnecting in 5 seconds..."
|
|
753
747
|
)
|
|
754
748
|
await asyncio.sleep(5)
|
|
749
|
+
await self._resync_after_reconnect(location_hilo_id, callback)
|
|
755
750
|
|
|
756
751
|
except asyncio.TimeoutError:
|
|
757
752
|
# Keepalive timeout: the connection was recently live, so start
|
|
@@ -765,15 +760,7 @@ class GraphQlHelper:
|
|
|
765
760
|
backoff_delay = min(backoff_delay * 2, self._BACKOFF_MAX)
|
|
766
761
|
if "query" in payload:
|
|
767
762
|
del payload["query"]
|
|
768
|
-
|
|
769
|
-
try:
|
|
770
|
-
await self.call_get_location_query(location_hilo_id)
|
|
771
|
-
LOG.debug("call_get_location_query success after reconnect")
|
|
772
|
-
except Exception as e2:
|
|
773
|
-
LOG.error(
|
|
774
|
-
"exception while RE-connecting, retrying: %s",
|
|
775
|
-
e2,
|
|
776
|
-
)
|
|
763
|
+
await self._resync_after_reconnect(location_hilo_id, callback)
|
|
777
764
|
|
|
778
765
|
except Exception as e:
|
|
779
766
|
LOG.debug(
|
|
@@ -785,21 +772,30 @@ class GraphQlHelper:
|
|
|
785
772
|
backoff_delay = min(backoff_delay * 2, self._BACKOFF_MAX)
|
|
786
773
|
if "query" in payload:
|
|
787
774
|
del payload["query"]
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
775
|
+
await self._resync_after_reconnect(location_hilo_id, callback)
|
|
776
|
+
|
|
777
|
+
async def _resync_after_reconnect(
|
|
778
|
+
self,
|
|
779
|
+
location_hilo_id: Optional[str],
|
|
780
|
+
callback: Optional[Callable[[str], None]],
|
|
781
|
+
) -> None:
|
|
782
|
+
if not location_hilo_id:
|
|
783
|
+
return
|
|
784
|
+
try:
|
|
785
|
+
hilo_ids = await self.call_get_location_query(location_hilo_id)
|
|
786
|
+
LOG.debug("call_get_location_query success after reconnect")
|
|
787
|
+
except Exception as err:
|
|
788
|
+
LOG.error("exception while RE-connecting, retrying: %s", err)
|
|
789
|
+
return
|
|
790
|
+
if callback:
|
|
791
|
+
for hilo_id in hilo_ids:
|
|
792
|
+
callback(hilo_id)
|
|
797
793
|
|
|
798
794
|
async def _get_access_token(self) -> str:
|
|
799
795
|
"""Get the access token."""
|
|
800
796
|
return await self._api.async_get_access_token()
|
|
801
797
|
|
|
802
|
-
def _handle_query_result(self, result: Dict[str, Any]) ->
|
|
798
|
+
def _handle_query_result(self, result: Dict[str, Any]) -> list[str]:
|
|
803
799
|
"""Handle the result of the GraphQL query for location and devices."""
|
|
804
800
|
devices_values: List[Dict[str, Any]] = result["getLocation"]["devices"]
|
|
805
801
|
|
|
@@ -813,7 +809,8 @@ class GraphQlHelper:
|
|
|
813
809
|
self._devices.devices.append(gw_dev)
|
|
814
810
|
|
|
815
811
|
attributes = self.mapper.map_query_values(devices_values)
|
|
816
|
-
self._devices.parse_values_received(attributes)
|
|
812
|
+
updated_devices = self._devices.parse_values_received(attributes)
|
|
813
|
+
return [device.hilo_id for device in updated_devices if device.hilo_id]
|
|
817
814
|
|
|
818
815
|
def _build_gateway_dict(self, raw_device: Dict[str, Any]) -> Dict[str, Any]:
|
|
819
816
|
"""Build a dictionary representing the gateway device from raw GraphQL data."""
|
|
@@ -829,6 +826,7 @@ class GraphQlHelper:
|
|
|
829
826
|
"type": "Gateway",
|
|
830
827
|
"category": "Gateway",
|
|
831
828
|
"id": 1,
|
|
829
|
+
"hilo_id": hilo_id,
|
|
832
830
|
"identifier": mac,
|
|
833
831
|
"sdi": mac,
|
|
834
832
|
"provider": 1,
|
|
@@ -847,20 +845,20 @@ class GraphQlHelper:
|
|
|
847
845
|
"disconnected": {"value": connection_status != "CONNECTED"},
|
|
848
846
|
}
|
|
849
847
|
|
|
850
|
-
def _handle_device_subscription_result(self, result: Dict[str, Any]) -> str:
|
|
848
|
+
def _handle_device_subscription_result(self, result: Dict[str, Any]) -> list[str]:
|
|
851
849
|
"""Handle the result of the GraphQL subscription for device updates."""
|
|
852
850
|
device_value: Dict[str, Any] = result["onAnyDeviceUpdated"]["device"]
|
|
853
851
|
attributes = self.mapper.map_device_subscription_values(device_value)
|
|
854
|
-
|
|
852
|
+
updated_devices = self._devices.parse_values_received(attributes)
|
|
855
853
|
# callback to update the device in the UI
|
|
856
|
-
LOG.debug("Device updated: %s",
|
|
857
|
-
return
|
|
854
|
+
LOG.debug("Device updated: %s", updated_devices)
|
|
855
|
+
return [device.hilo_id for device in updated_devices if device.hilo_id]
|
|
858
856
|
|
|
859
|
-
def _handle_location_subscription_result(self, result: Dict[str, Any]) -> str:
|
|
857
|
+
def _handle_location_subscription_result(self, result: Dict[str, Any]) -> list[str]:
|
|
860
858
|
"""Handle the result of the GraphQL subscription for location updates."""
|
|
861
859
|
location_value: Dict[str, Any] = result["onAnyLocationUpdated"]["location"]
|
|
862
860
|
attributes = self.mapper.map_location_subscription_values(location_value)
|
|
863
|
-
|
|
861
|
+
updated_devices = self._devices.parse_values_received(attributes)
|
|
864
862
|
# callback to update the device in the UI
|
|
865
|
-
LOG.debug("Device updated: %s",
|
|
866
|
-
return
|
|
863
|
+
LOG.debug("Device updated: %s", updated_devices)
|
|
864
|
+
return [device.hilo_id for device in updated_devices if device.hilo_id]
|
|
@@ -8,7 +8,7 @@ from unittest.mock import AsyncMock, MagicMock
|
|
|
8
8
|
import pytest
|
|
9
9
|
|
|
10
10
|
from pyhilo import API, AbstractAuth
|
|
11
|
-
from pyhilo.const import API_HOSTNAME
|
|
11
|
+
from pyhilo.const import API_HOSTNAME, SUBSCRIPTION_KEY
|
|
12
12
|
|
|
13
13
|
URN = "urn:hilo:crm:abc-123"
|
|
14
14
|
|
|
@@ -133,3 +133,38 @@ async def test_deprecated_oauth_session_still_works(
|
|
|
133
133
|
assert await api.async_get_access_token() == TOKEN
|
|
134
134
|
oauth_session.async_ensure_token_valid.assert_awaited_once()
|
|
135
135
|
assert api.urn == URN
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@pytest.mark.parametrize(
|
|
139
|
+
"secret",
|
|
140
|
+
[
|
|
141
|
+
pytest.param(TOKEN, id="bearer_token"),
|
|
142
|
+
pytest.param(SUBSCRIPTION_KEY, id="subscription_key"),
|
|
143
|
+
],
|
|
144
|
+
)
|
|
145
|
+
async def test_trace_logs_redact_request_credentials(
|
|
146
|
+
mock_session: MagicMock, caplog: pytest.LogCaptureFixture, secret: str
|
|
147
|
+
) -> None:
|
|
148
|
+
auth = AsyncMock(spec=AbstractAuth)
|
|
149
|
+
auth.async_get_access_token.return_value = TOKEN
|
|
150
|
+
api = API(session=mock_session, auth=auth, log_traces=True)
|
|
151
|
+
|
|
152
|
+
with caplog.at_level(logging.DEBUG):
|
|
153
|
+
await api._async_request("get", "/endpoint")
|
|
154
|
+
|
|
155
|
+
assert secret not in caplog.text
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
async def test_trace_logs_redact_signalr_negotiate_token(
|
|
159
|
+
mock_session: MagicMock, caplog: pytest.LogCaptureFixture
|
|
160
|
+
) -> None:
|
|
161
|
+
response = mock_session.request.return_value.__aenter__.return_value
|
|
162
|
+
response.json.return_value = {"url": "https://hub", "accessToken": "hub-token"}
|
|
163
|
+
auth = AsyncMock(spec=AbstractAuth)
|
|
164
|
+
auth.async_get_access_token.return_value = TOKEN
|
|
165
|
+
api = API(session=mock_session, auth=auth, log_traces=True)
|
|
166
|
+
|
|
167
|
+
with caplog.at_level(logging.DEBUG):
|
|
168
|
+
await api._async_request("post", "/DeviceHub/negotiate")
|
|
169
|
+
|
|
170
|
+
assert "hub-token" not in caplog.text
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"""Tests for GraphQlHelper Gateway creation and device subscription updates."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import ssl
|
|
6
|
+
from unittest.mock import AsyncMock, MagicMock, patch
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
from pyhilo import API, HiloDevice
|
|
11
|
+
from pyhilo.devices import Devices
|
|
12
|
+
from pyhilo.graphql import GraphQlHelper
|
|
13
|
+
|
|
14
|
+
GATEWAY_HILO_ID = "urn:hilo:ihub:AA11BB22CC33:0"
|
|
15
|
+
TSTAT_HILO_ID = "urn:hilo:philo:1a2b3c4d5e6f0001:0"
|
|
16
|
+
SWITCH_HILO_ID = "urn:hilo:philo:9a8b7c6d5e4f0002:0"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _make_helper() -> tuple[GraphQlHelper, Devices]:
|
|
20
|
+
auth = MagicMock()
|
|
21
|
+
auth.async_get_access_token = AsyncMock(return_value="token")
|
|
22
|
+
api = API(session=MagicMock(), auth=auth)
|
|
23
|
+
devices = Devices(api)
|
|
24
|
+
devices.location_id = 42
|
|
25
|
+
devices.location_hilo_id = "urn:hilo:crm:00000-abcdef:0"
|
|
26
|
+
helper = GraphQlHelper(api, devices)
|
|
27
|
+
helper._ssl_context = MagicMock(spec=ssl.SSLContext)
|
|
28
|
+
return helper, devices
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _gateway_payload(
|
|
32
|
+
connection_status: str, device_type: str = "Hub"
|
|
33
|
+
) -> dict[str, object]:
|
|
34
|
+
return {
|
|
35
|
+
"deviceType": device_type,
|
|
36
|
+
"hiloId": GATEWAY_HILO_ID,
|
|
37
|
+
"physicalAddress": "AA11BB22CC33",
|
|
38
|
+
"connectionStatus": connection_status,
|
|
39
|
+
"controllerSoftwareVersion": "1.2.3",
|
|
40
|
+
"lastConnectionTime": "2026-11-11T12:00:00Z",
|
|
41
|
+
"willBeConnectedToSmartMeter": True,
|
|
42
|
+
"zigBeeChannel": 15,
|
|
43
|
+
"zigBeePairingModeEnhanced": False,
|
|
44
|
+
"smartMeterZigBeeChannel": 24,
|
|
45
|
+
"smartMeterPairingStatus": True,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _make_helper_with_gateway() -> tuple[GraphQlHelper, Devices, HiloDevice]:
|
|
50
|
+
helper, devices = _make_helper()
|
|
51
|
+
helper._handle_query_result(
|
|
52
|
+
{"getLocation": {"devices": [_gateway_payload("CONNECTED")]}}
|
|
53
|
+
)
|
|
54
|
+
gateway = devices.find_device(GATEWAY_HILO_ID)
|
|
55
|
+
assert gateway is not None
|
|
56
|
+
return helper, devices, gateway
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@pytest.mark.parametrize(
|
|
60
|
+
("connection_status", "expected_available"),
|
|
61
|
+
[
|
|
62
|
+
pytest.param("CONNECTED", True, id="connected"),
|
|
63
|
+
pytest.param("DISCONNECTED", False, id="disconnected"),
|
|
64
|
+
],
|
|
65
|
+
)
|
|
66
|
+
def test_gateway_query_populates_hilo_id_and_availability(
|
|
67
|
+
connection_status: str, expected_available: bool
|
|
68
|
+
) -> None:
|
|
69
|
+
"""getLocation creates the Gateway with its real hilo_id and availability."""
|
|
70
|
+
helper, devices = _make_helper()
|
|
71
|
+
|
|
72
|
+
updated_ids = helper._handle_query_result(
|
|
73
|
+
{"getLocation": {"devices": [_gateway_payload(connection_status)]}}
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
gateway = devices.find_device(GATEWAY_HILO_ID)
|
|
77
|
+
assert gateway is not None
|
|
78
|
+
assert updated_ids == [GATEWAY_HILO_ID]
|
|
79
|
+
assert gateway.hilo_id == GATEWAY_HILO_ID
|
|
80
|
+
assert gateway.identifier == "AA11BB22CC33"
|
|
81
|
+
assert gateway.available is expected_available
|
|
82
|
+
assert gateway.get_value("online_status") == connection_status
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_gateway_device_subscription_updates_availability_and_notifies_callback() -> (
|
|
86
|
+
None
|
|
87
|
+
):
|
|
88
|
+
"""onAnyDeviceUpdated updates Gateway availability and passes its hilo_id to callback."""
|
|
89
|
+
helper, _, gateway = _make_helper_with_gateway()
|
|
90
|
+
notified: list[str] = []
|
|
91
|
+
sse_payload: dict[str, object] = {
|
|
92
|
+
"data": {
|
|
93
|
+
"onAnyDeviceUpdated": {
|
|
94
|
+
"device": _gateway_payload("DISCONNECTED", device_type="hub"),
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
retry, had_success = helper._handle_sse_message(
|
|
100
|
+
sse_payload, helper._handle_device_subscription_result, notified.append
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
assert (retry, had_success) == (False, True)
|
|
104
|
+
assert gateway.available is False
|
|
105
|
+
assert gateway.get_value("online_status") == "DISCONNECTED"
|
|
106
|
+
assert notified == [GATEWAY_HILO_ID]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_unknown_hilo_id_reading_does_not_overwrite_gateway_availability() -> None:
|
|
110
|
+
"""GraphQL readings for an unknown hiloId must not fall back to the Gateway device."""
|
|
111
|
+
helper, _, gateway = _make_helper_with_gateway()
|
|
112
|
+
notified: list[str] = []
|
|
113
|
+
sse_payload: dict[str, object] = {
|
|
114
|
+
"data": {
|
|
115
|
+
"onAnyDeviceUpdated": {
|
|
116
|
+
"device": {
|
|
117
|
+
"deviceType": "Switch",
|
|
118
|
+
"hiloId": "urn:hilo:philo:unpaired-switch:0",
|
|
119
|
+
"connectionStatus": "DISCONNECTED",
|
|
120
|
+
"state": "OFF",
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
helper._handle_sse_message(
|
|
127
|
+
sse_payload, helper._handle_device_subscription_result, notified.append
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
assert gateway.available is True
|
|
131
|
+
assert notified == []
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
async def test_resync_after_reconnect_updates_gateway_and_notifies_callback() -> None:
|
|
135
|
+
"""SSE reconnect resync parses getLocation and forwards updated hilo_ids to callback."""
|
|
136
|
+
helper, devices, gateway = _make_helper_with_gateway()
|
|
137
|
+
response = MagicMock()
|
|
138
|
+
response.raise_for_status = MagicMock()
|
|
139
|
+
response.json.return_value = {
|
|
140
|
+
"data": {"getLocation": {"devices": [_gateway_payload("DISCONNECTED")]}}
|
|
141
|
+
}
|
|
142
|
+
client = AsyncMock()
|
|
143
|
+
client.post = AsyncMock(return_value=response)
|
|
144
|
+
client_cm = AsyncMock()
|
|
145
|
+
client_cm.__aenter__.return_value = client
|
|
146
|
+
|
|
147
|
+
notified: list[str] = []
|
|
148
|
+
with patch("pyhilo.graphql.httpx.AsyncClient", return_value=client_cm):
|
|
149
|
+
await helper._resync_after_reconnect(devices.location_hilo_id, notified.append)
|
|
150
|
+
|
|
151
|
+
assert gateway.available is False
|
|
152
|
+
assert notified == [GATEWAY_HILO_ID]
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def test_location_subscription_updates_devices_and_notifies_each_hilo_id() -> None:
|
|
156
|
+
"""onAnyLocationUpdated updates device availability and invokes callback per hilo_id."""
|
|
157
|
+
helper, devices, gateway = _make_helper_with_gateway()
|
|
158
|
+
tstat = devices.generate_device(
|
|
159
|
+
{
|
|
160
|
+
"id": 100,
|
|
161
|
+
"hilo_id": TSTAT_HILO_ID,
|
|
162
|
+
"name": "Living Room",
|
|
163
|
+
"type": "Thermostat",
|
|
164
|
+
"provider": 1,
|
|
165
|
+
"supportedAttributes": "Disconnected, CurrentTemperature",
|
|
166
|
+
"settableAttributes": "",
|
|
167
|
+
"Disconnected": {"value": False},
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
switch = devices.generate_device(
|
|
171
|
+
{
|
|
172
|
+
"id": 101,
|
|
173
|
+
"hilo_id": SWITCH_HILO_ID,
|
|
174
|
+
"name": "Porch Light",
|
|
175
|
+
"type": "LightSwitch",
|
|
176
|
+
"provider": 1,
|
|
177
|
+
"supportedAttributes": "Disconnected, OnOff",
|
|
178
|
+
"settableAttributes": "OnOff",
|
|
179
|
+
"Disconnected": {"value": True},
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
weather_station = devices.generate_device(
|
|
183
|
+
{
|
|
184
|
+
"id": 102,
|
|
185
|
+
"hilo_id": "urn:hilo:netatmo:station:0",
|
|
186
|
+
"name": "Weather Station",
|
|
187
|
+
"type": "IndoorWeatherStation",
|
|
188
|
+
"provider": 2,
|
|
189
|
+
"supportedAttributes": "Disconnected",
|
|
190
|
+
"settableAttributes": "",
|
|
191
|
+
"Disconnected": {"value": True},
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
devices.devices.extend([tstat, switch, weather_station])
|
|
195
|
+
|
|
196
|
+
notified: list[str] = []
|
|
197
|
+
sse_payload: dict[str, object] = {
|
|
198
|
+
"data": {
|
|
199
|
+
"onAnyLocationUpdated": {
|
|
200
|
+
"transmissionTime": "2026-11-11T12:05:00Z",
|
|
201
|
+
"operationId": "00000000-0000-0000-0000-000000000010",
|
|
202
|
+
"location": {
|
|
203
|
+
"devices": [
|
|
204
|
+
{
|
|
205
|
+
"__typename": "Gateway",
|
|
206
|
+
"hiloId": GATEWAY_HILO_ID,
|
|
207
|
+
"connectionStatus": "DISCONNECTED",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"__typename": "BasicThermostat",
|
|
211
|
+
"hiloId": TSTAT_HILO_ID,
|
|
212
|
+
"connectionStatus": "DISCONNECTED",
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"__typename": "BasicSwitch",
|
|
216
|
+
"hiloId": SWITCH_HILO_ID,
|
|
217
|
+
"connectionStatus": "CONNECTED",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"__typename": "BasicDevice",
|
|
221
|
+
"hiloId": "urn:hilo:netatmo:station:0",
|
|
222
|
+
"connectionStatus": None,
|
|
223
|
+
},
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
retry, had_success = helper._handle_sse_message(
|
|
231
|
+
sse_payload, helper._handle_location_subscription_result, notified.append
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
assert (retry, had_success) == (False, True)
|
|
235
|
+
assert gateway.available is False
|
|
236
|
+
assert gateway.get_value("online_status") == "DISCONNECTED"
|
|
237
|
+
assert tstat.available is False
|
|
238
|
+
assert switch.available is True
|
|
239
|
+
assert weather_station.available is False
|
|
240
|
+
assert notified == [GATEWAY_HILO_ID, TSTAT_HILO_ID, SWITCH_HILO_ID]
|
|
@@ -124,3 +124,68 @@ def test_thermostat_humidity_absent_field() -> None:
|
|
|
124
124
|
attributes = GraphqlValueMapper().map_device_subscription_values(device)
|
|
125
125
|
|
|
126
126
|
assert not [a for a in attributes if a["attribute"] == "Humidity"]
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@pytest.mark.parametrize(
|
|
130
|
+
("connection_status", "expected"),
|
|
131
|
+
[
|
|
132
|
+
pytest.param("CONNECTED", False, id="connected"),
|
|
133
|
+
pytest.param("DISCONNECTED", True, id="disconnected"),
|
|
134
|
+
],
|
|
135
|
+
)
|
|
136
|
+
def test_location_subscription_maps_connection_status(
|
|
137
|
+
connection_status: str, expected: bool
|
|
138
|
+
) -> None:
|
|
139
|
+
"""Location updates only carry __typename, hiloId, and connectionStatus."""
|
|
140
|
+
payload: dict[str, object] = {
|
|
141
|
+
"devices": [
|
|
142
|
+
{
|
|
143
|
+
"__typename": "BasicThermostat",
|
|
144
|
+
"hiloId": "urn:hilo:philo:1a2b3c4d5e6f0001:0",
|
|
145
|
+
"connectionStatus": connection_status,
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
attributes = GraphqlValueMapper().map_location_subscription_values(payload)
|
|
151
|
+
|
|
152
|
+
assert {a["attribute"]: a["value"] for a in attributes} == {
|
|
153
|
+
"Unpaired": False,
|
|
154
|
+
"Disconnected": expected,
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def test_location_subscription_skips_basic_device() -> None:
|
|
159
|
+
"""Unmigrated SignalR BasicDevice stubs produce no location update readings."""
|
|
160
|
+
payload: dict[str, object] = {
|
|
161
|
+
"devices": [
|
|
162
|
+
{
|
|
163
|
+
"__typename": "BasicDevice",
|
|
164
|
+
"hiloId": "urn:hilo:netatmo:station:0",
|
|
165
|
+
"connectionStatus": None,
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
assert GraphqlValueMapper().map_location_subscription_values(payload) == []
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def test_location_subscription_maps_gateway_online_status() -> None:
|
|
174
|
+
"""Gateway entries in location updates also emit onlineStatus."""
|
|
175
|
+
payload: dict[str, object] = {
|
|
176
|
+
"devices": [
|
|
177
|
+
{
|
|
178
|
+
"__typename": "Gateway",
|
|
179
|
+
"hiloId": "hub-1",
|
|
180
|
+
"connectionStatus": "DISCONNECTED",
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
attributes = GraphqlValueMapper().map_location_subscription_values(payload)
|
|
186
|
+
|
|
187
|
+
assert {a["attribute"]: a["value"] for a in attributes} == {
|
|
188
|
+
"Unpaired": False,
|
|
189
|
+
"Disconnected": True,
|
|
190
|
+
"onlineStatus": "DISCONNECTED",
|
|
191
|
+
}
|
|
@@ -907,14 +907,14 @@ wheels = [
|
|
|
907
907
|
|
|
908
908
|
[[package]]
|
|
909
909
|
name = "pytest-asyncio"
|
|
910
|
-
version = "1.
|
|
910
|
+
version = "1.5.0"
|
|
911
911
|
source = { registry = "https://pypi.org/simple" }
|
|
912
912
|
dependencies = [
|
|
913
913
|
{ name = "pytest" },
|
|
914
914
|
]
|
|
915
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
915
|
+
sdist = { url = "https://files.pythonhosted.org/packages/2c/de/80724f9b5b9eca1a654179cae6edc51aaa0a355a9834a736e2a188b91780/pytest_asyncio-1.5.0.tar.gz", hash = "sha256:92c8fa83ca419fd0d4bd6a34df6520dae435841d3733c319343249492adf37f7", size = 146227, upload-time = "2026-11-12T16:35:49.845Z" }
|
|
916
916
|
wheels = [
|
|
917
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
917
|
+
{ url = "https://files.pythonhosted.org/packages/27/2d/e600d8f47597a803641704aba367c7266cd621f86561ec36da9888f160ec/pytest_asyncio-1.5.0-py3-none-any.whl", hash = "sha256:557f255ee03cc84f84a8d5f438bc9c6e0f714bf86970ae743c7ecb5a38d7e07d", size = 17215, upload-time = "2026-11-12T16:35:48.446Z" },
|
|
918
918
|
]
|
|
919
919
|
|
|
920
920
|
[[package]]
|
|
@@ -957,7 +957,7 @@ wheels = [
|
|
|
957
957
|
|
|
958
958
|
[[package]]
|
|
959
959
|
name = "python-hilo"
|
|
960
|
-
version = "2026.11.
|
|
960
|
+
version = "2026.11.3"
|
|
961
961
|
source = { editable = "." }
|
|
962
962
|
dependencies = [
|
|
963
963
|
{ name = "aiofiles" },
|
|
@@ -1040,27 +1040,27 @@ wheels = [
|
|
|
1040
1040
|
|
|
1041
1041
|
[[package]]
|
|
1042
1042
|
name = "ruff"
|
|
1043
|
-
version = "0.17.
|
|
1043
|
+
version = "0.17.5"
|
|
1044
1044
|
source = { registry = "https://pypi.org/simple" }
|
|
1045
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
1045
|
+
sdist = { url = "https://files.pythonhosted.org/packages/86/cc/7b71512eb8b49926efb887cc66c74dd993642943c29eba51a877f6b85692/ruff-0.17.5.tar.gz", hash = "sha256:625e57d80cd43352d12ea81690f3eac46cddc8c0f35026d137fb0f157f94592e", size = 5368382, upload-time = "2026-11-12T17:54:55.04Z" }
|
|
1046
1046
|
wheels = [
|
|
1047
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1048
|
-
{ url = "https://files.pythonhosted.org/packages/72/
|
|
1049
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1050
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1051
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1052
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1053
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1054
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1055
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1056
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1057
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1058
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1059
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1060
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1061
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1062
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1063
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1047
|
+
{ url = "https://files.pythonhosted.org/packages/d4/f2/61df414cb4338617290a9023ad09486e207fb9a6d09357a7be34f2e369a4/ruff-0.17.5-py3-none-linux_armv6l.whl", hash = "sha256:d511dd302982e46a285528942fa6557d57730edc4bdb9def95e86a2603d77396", size = 10231309, upload-time = "2026-11-12T17:54:09.314Z" },
|
|
1048
|
+
{ url = "https://files.pythonhosted.org/packages/d1/72/8ed970f3361f7c8d3f8e1b3b1af27cf086bc4b3a6b62ec20e21a1aaaaff5/ruff-0.17.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b72fbc232e328bdbb9cdddf4f1aedcd61bd1aa64d75fc012114b4add0bd7f26b", size = 10250018, upload-time = "2026-11-12T17:54:11.983Z" },
|
|
1049
|
+
{ url = "https://files.pythonhosted.org/packages/dc/4b/8b10f6c9d0a18413301ae8dd2af9d180a81bb738b1b731d944a37404c523/ruff-0.17.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:6f0db748508f04a04e3fbebcc636a5c8b3bd76274f8ed28f497c44d75c2ea2d7", size = 9504737, upload-time = "2026-11-12T17:54:14.567Z" },
|
|
1050
|
+
{ url = "https://files.pythonhosted.org/packages/b7/ea/1b3afa3943239dede7a0755ea139bdb51879f0f3f96f92894081d5c7d2e5/ruff-0.17.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6f6a7b138edf9cc402ca736a59d9525e6d766e5395760b72e7e146e6251ac963", size = 10168006, upload-time = "2026-11-12T17:54:17.195Z" },
|
|
1051
|
+
{ url = "https://files.pythonhosted.org/packages/31/08/ee641daa45f83792f91274b65796cb011f1065f588911bfa3909ad9e31e7/ruff-0.17.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e52622ecf3a0df9d03e796fe3eed4aa085adda65520db7e0619cbd2192a97342", size = 10043751, upload-time = "2026-11-12T17:54:19.815Z" },
|
|
1052
|
+
{ url = "https://files.pythonhosted.org/packages/f8/cf/1c59fdb42d0b5671ad5b160636fab4005ee28db72cb06aef6e3f3c04f377/ruff-0.17.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54c0f67d1be11b55d12c184a819fc229f5eee3ef45c16c4fcad41258e83b4882", size = 10690562, upload-time = "2026-11-12T17:54:22.789Z" },
|
|
1053
|
+
{ url = "https://files.pythonhosted.org/packages/49/c5/578074716173fb0c1591e9648a9f85c469888d9530cb35b89b757dc1208b/ruff-0.17.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dd0dfe7c6fe5a447fce467c58e69893be1d9a7e4378f5b9906432da33d94a97f", size = 11338465, upload-time = "2026-11-12T17:54:25.523Z" },
|
|
1054
|
+
{ url = "https://files.pythonhosted.org/packages/aa/b9/d6428bcf5ed88f4dc1d6e3417ee350236ed36e7a35f9477b727c00e437bf/ruff-0.17.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ec4ecf40fb4d6e1265b009dbe551727920926fc0f769070c452d6d84b422a74d", size = 10895501, upload-time = "2026-11-12T17:54:28.441Z" },
|
|
1055
|
+
{ url = "https://files.pythonhosted.org/packages/f2/8a/1e29c0c3785ae7e5cd0d54ee8717a08867ef71545796340be4c653c57e24/ruff-0.17.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40ca8afaac309b41a5b2e09e4e7beb1f824826b93c25697c4d74f573324fba4e", size = 10613231, upload-time = "2026-11-12T17:54:30.862Z" },
|
|
1056
|
+
{ url = "https://files.pythonhosted.org/packages/32/b6/88944350c14bb90651014d678ad554e233ae2a79c14ad52101845f93d15b/ruff-0.17.5-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:8e85601bd6d9b6c3e3b95c0e0dccdbac1d23c6bcef006d187fbcddaf8225a5df", size = 10562789, upload-time = "2026-11-12T17:54:33.869Z" },
|
|
1057
|
+
{ url = "https://files.pythonhosted.org/packages/6f/fd/2792e955b0bf54295cdcdddc4bb3f380c0790d7e60e789f528a9e6e48a31/ruff-0.17.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f93d2b7d449ed9545304f6923699ca20d13c675b69f258481709a08ae61076db", size = 10069824, upload-time = "2026-11-12T17:54:36.663Z" },
|
|
1058
|
+
{ url = "https://files.pythonhosted.org/packages/07/9c/d7cad341b4c19237948a6dd1fcea1c9c39c9d08b70f22f0e157d1236ebd6/ruff-0.17.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0e5c125c5b31dc8efc948d41357496a4c4a312977565ccba740030efdff83580", size = 10038961, upload-time = "2026-11-12T17:54:39.452Z" },
|
|
1059
|
+
{ url = "https://files.pythonhosted.org/packages/cc/a1/9cd0d4c371ddc70267d3bd557e718e2bdfb94c25e49d25605edfabb764bd/ruff-0.17.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:50dfc3c6b3ebd0a932f11dfd579bd42234b0b7137e68940eb6abdbfdb9d69697", size = 10385012, upload-time = "2026-11-12T17:54:41.808Z" },
|
|
1060
|
+
{ url = "https://files.pythonhosted.org/packages/8f/a9/35f078ce98d4df318328ea5270382b5b65e680f7953b3db54f8e009c420c/ruff-0.17.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:86bd1f3b83c25f9b8055c6e796f0685b39d3127ce947322098c3108cf82fd586", size = 10793672, upload-time = "2026-11-12T17:54:44.342Z" },
|
|
1061
|
+
{ url = "https://files.pythonhosted.org/packages/2c/a5/2e136dede2a88aaaf54498bbbdc81bc810f788ef6ef01efb97037d73cd1d/ruff-0.17.5-py3-none-win32.whl", hash = "sha256:e1546609b2ad73f1d6c5c076881b788672b7b3cc3283981182cbdbb6524ed88a", size = 9929908, upload-time = "2026-11-12T17:54:47.067Z" },
|
|
1062
|
+
{ url = "https://files.pythonhosted.org/packages/ec/8c/e4db9ae1e0ee233c04df007ab6d0d42f799ae9abd95d352b6092ee7bc4bf/ruff-0.17.5-py3-none-win_amd64.whl", hash = "sha256:aa415d57c244299279901d776607fee3df7831c2a7435433fbfacde8632c6550", size = 10275454, upload-time = "2026-11-12T17:54:49.401Z" },
|
|
1063
|
+
{ url = "https://files.pythonhosted.org/packages/e6/65/a1648bc1550e7683bf7bf1e2ce2485c9f8535cbca6cca9ec7b73cc12fb8e/ruff-0.17.5-py3-none-win_arm64.whl", hash = "sha256:64a6fd668a336df959c522991de33e9e3c8be463afc0c9ac8f029f9d19ef756e", size = 9849020, upload-time = "2026-11-12T17:54:52.055Z" },
|
|
1064
1064
|
]
|
|
1065
1065
|
|
|
1066
1066
|
[[package]]
|
|
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
|
{python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/postman/hilo-prod.postman_environment.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_hilo-2026.11.2 → python_hilo-2026.11.3}/doc/signalr/challengehub/ChallengeAdded.json
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
|
|
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
|