Skip to content

Commit 39f5688

Browse files
authored
Merge pull request #279 from AbigailAsselin-Hilo/fix/light_state
Add support for whitebulb and normalize OnOff attribute state
2 parents e8c4706 + 184fbe1 commit 39f5688

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "python-hilo",
3-
"version": "2025.4.1",
3+
"version": "2025.4.2",
44
"private": true,
55
"description": "A Python3, async interface to the Hilo API",
66
"scripts": {

pyhilo/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
LOG: Final = logging.getLogger(__package__)
88
DEFAULT_STATE_FILE: Final = "hilo_state.yaml"
99
REQUEST_RETRY: Final = 9
10-
PYHILO_VERSION: Final = "2025.4.01"
10+
PYHILO_VERSION: Final = "2025.4.02"
1111
# TODO: Find a way to keep previous line in sync with pyproject.toml automatically
1212

1313
CONTENT_TYPE_FORM: Final = "application/x-www-form-urlencoded"

pyhilo/device/graphql_value_mapper.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class GraphqlValueMapper:
99
A class to map GraphQL values to DeviceReading instances.
1010
"""
1111

12+
OnState = "on"
13+
1214
def map_query_values(self, values: Dict[str, Any]) -> list[Dict[str, Any]]:
1315
readings: list[Dict[str, Any]] = []
1416
for device in values:
@@ -57,6 +59,8 @@ def _map_devices_values(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
5759
attributes.extend(self._build_gateway(device))
5860
case "colorbulb":
5961
attributes.extend(self._build_light(device))
62+
case "whitebulb":
63+
attributes.extend(self._build_light(device))
6064
case "dimmer":
6165
attributes.extend(self._build_dimmer(device))
6266
case "switch":
@@ -354,6 +358,11 @@ def _build_charge_controller(self, device: Dict[str, Any]) -> list[Dict[str, Any
354358
attributes.append(
355359
self.build_attribute(device["hiloId"], "CcrMode", device["ccrMode"])
356360
)
361+
attributes.append(
362+
self.build_attribute(
363+
device["hiloId"], "OnOff", device["state"].lower() == self.OnState
364+
)
365+
)
357366
return attributes
358367

359368
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]]:
372381
if device.get("power") is not None:
373382
attributes.append(self._map_power(device))
374383
attributes.append(
375-
self.build_attribute(device["hiloId"], "Status", device["state"])
384+
self.build_attribute(
385+
device["hiloId"], "Status", device["state"].lower() == self.OnState
386+
)
376387
)
377388
attributes.append(
378-
self.build_attribute(device["hiloId"], "OnOff", device["state"])
389+
self.build_attribute(
390+
device["hiloId"], "OnOff", device["state"].lower() == self.OnState
391+
)
379392
)
380393
return attributes
381394

@@ -390,7 +403,9 @@ def _build_dimmer(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
390403
)
391404
)
392405
attributes.append(
393-
self.build_attribute(device["hiloId"], "OnOff", device["state"])
406+
self.build_attribute(
407+
device["hiloId"], "OnOff", device["state"].lower() == self.OnState
408+
)
394409
)
395410
return attributes
396411

@@ -420,7 +435,9 @@ def _build_light(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
420435
)
421436
)
422437
attributes.append(
423-
self.build_attribute(device["hiloId"], "OnOff", device["state"])
438+
self.build_attribute(
439+
device["hiloId"], "OnOff", device["state"].lower() == self.OnState
440+
)
424441
)
425442
return attributes
426443

pyhilo/util/state.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class RegistrationDict(TypedDict, total=False):
5858

5959
class FirebaseDict(TypedDict):
6060
"""Represents a dictionary containing Firebase information."""
61+
6162
fid: str | None
6263
name: str | None
6364
token: TokenDict

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ exclude = ".venv/.*"
4040

4141
[tool.poetry]
4242
name = "python-hilo"
43-
version = "2025.4.1"
43+
version = "2025.4.2"
4444
description = "A Python3, async interface to the Hilo API"
4545
readme = "README.md"
4646
authors = ["David Vallee Delisle <[email protected]>"]

0 commit comments

Comments
 (0)