diff --git a/package.json b/package.json index 6215273..64aa974 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/pyhilo/const.py b/pyhilo/const.py index bc360ad..334d6b6 100755 --- a/pyhilo/const.py +++ b/pyhilo/const.py @@ -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" diff --git a/pyhilo/device/graphql_value_mapper.py b/pyhilo/device/graphql_value_mapper.py index cb66bf6..9ffc39d 100644 --- a/pyhilo/device/graphql_value_mapper.py +++ b/pyhilo/device/graphql_value_mapper.py @@ -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: @@ -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": @@ -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]]: @@ -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 @@ -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 @@ -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 diff --git a/pyhilo/util/state.py b/pyhilo/util/state.py index 0fd3951..08fe3f1 100644 --- a/pyhilo/util/state.py +++ b/pyhilo/util/state.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 6daf3c8..f5278e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "]