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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "python-hilo",
"version": "2025.4.1",
"version": "2025.4.2",
"private": true,
"description": "A Python3, async interface to the Hilo API",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion pyhilo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
LOG: Final = logging.getLogger(__package__)
DEFAULT_STATE_FILE: Final = "hilo_state.yaml"
REQUEST_RETRY: Final = 9
PYHILO_VERSION: Final = "2025.4.01"
PYHILO_VERSION: Final = "2025.4.02"
# TODO: Find a way to keep previous line in sync with pyproject.toml automatically

CONTENT_TYPE_FORM: Final = "application/x-www-form-urlencoded"
Expand Down
25 changes: 21 additions & 4 deletions pyhilo/device/graphql_value_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class GraphqlValueMapper:
A class to map GraphQL values to DeviceReading instances.
"""

OnState = "on"

def map_query_values(self, values: Dict[str, Any]) -> list[Dict[str, Any]]:
readings: list[Dict[str, Any]] = []
for device in values:
Expand Down Expand Up @@ -57,6 +59,8 @@ def _map_devices_values(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
attributes.extend(self._build_gateway(device))
case "colorbulb":
attributes.extend(self._build_light(device))
case "whitebulb":
attributes.extend(self._build_light(device))
case "dimmer":
attributes.extend(self._build_dimmer(device))
case "switch":
Expand Down Expand Up @@ -354,6 +358,11 @@ def _build_charge_controller(self, device: Dict[str, Any]) -> list[Dict[str, Any
attributes.append(
self.build_attribute(device["hiloId"], "CcrMode", device["ccrMode"])
)
attributes.append(
self.build_attribute(
device["hiloId"], "OnOff", device["state"].lower() == self.OnState
)
)
return attributes

def _build_charging_point(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
Expand All @@ -372,10 +381,14 @@ def _build_switch(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
if device.get("power") is not None:
attributes.append(self._map_power(device))
attributes.append(
self.build_attribute(device["hiloId"], "Status", device["state"])
self.build_attribute(
device["hiloId"], "Status", device["state"].lower() == self.OnState
)
)
attributes.append(
self.build_attribute(device["hiloId"], "OnOff", device["state"])
self.build_attribute(
device["hiloId"], "OnOff", device["state"].lower() == self.OnState
)
)
return attributes

Expand All @@ -390,7 +403,9 @@ def _build_dimmer(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
)
)
attributes.append(
self.build_attribute(device["hiloId"], "OnOff", device["state"])
self.build_attribute(
device["hiloId"], "OnOff", device["state"].lower() == self.OnState
)
)
return attributes

Expand Down Expand Up @@ -420,7 +435,9 @@ def _build_light(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
)
)
attributes.append(
self.build_attribute(device["hiloId"], "OnOff", device["state"])
self.build_attribute(
device["hiloId"], "OnOff", device["state"].lower() == self.OnState
)
)
return attributes

Expand Down
1 change: 1 addition & 0 deletions pyhilo/util/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class RegistrationDict(TypedDict, total=False):

class FirebaseDict(TypedDict):
"""Represents a dictionary containing Firebase information."""

fid: str | None
name: str | None
token: TokenDict
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exclude = ".venv/.*"

[tool.poetry]
name = "python-hilo"
version = "2025.4.1"
version = "2025.4.2"
description = "A Python3, async interface to the Hilo API"
readme = "README.md"
authors = ["David Vallee Delisle <me@dvd.dev>"]
Expand Down
Loading