Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyhilo/device/graphql_value_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _map_to_device_reading(

def _build_smart_meter(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
attributes = []
if device.get("zigbeeChannel") is not None:
if device.get("zigBeeChannel") is not None:
attributes.append(
self.build_attribute(
device["hiloId"], "ZigbeeChannel", device["zigBeeChannel"]
Expand Down
23 changes: 23 additions & 0 deletions tests/test_graphql_value_mapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Tests for mapping GraphQL subscription payloads to device attributes."""

import json
from pathlib import Path

from pyhilo.device.graphql_value_mapper import GraphqlValueMapper

PAYLOADS = Path(__file__).parent.parent / "doc" / "graphql"


def _device(filename: str) -> dict:
payload = json.loads((PAYLOADS / filename).read_text(encoding="utf-8"))
return payload["data"]["onAnyDeviceUpdated"]["device"]


def test_smart_meter_maps_zigbee_channel() -> None:
"""The meter's Zigbee channel is reported as the ZigbeeChannel attribute."""
attributes = GraphqlValueMapper().map_device_subscription_values(
_device("onAnyDeviceUpdated-meter.json")
)

channel = [a["value"] for a in attributes if a["attribute"] == "ZigbeeChannel"]
assert channel == [24]
Loading