From 5feba11d043dae1c64dc36c2d7fe6205ea915d5f Mon Sep 17 00:00:00 2001 From: "Ian C." <108159253+ic-dev21@users.noreply.github.com> Date: Sun, 30 Nov 2025 16:45:37 -0500 Subject: [PATCH 1/5] Update api.py --- pyhilo/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyhilo/api.py b/pyhilo/api.py index d02f5d9..07e4b33 100755 --- a/pyhilo/api.py +++ b/pyhilo/api.py @@ -141,7 +141,7 @@ async def async_get_access_token(self) -> str: await self._oauth_session.async_ensure_token_valid() access_token = str(self._oauth_session.token["access_token"]) - LOG.debug("LOCALLY Websocket access token is %s", access_token) + LOG.debug("Websocket access token is %s", access_token) return str(self._oauth_session.token["access_token"]) From 9bf575a30ec8bacb8e9519e92f75740ec76f1f34 Mon Sep 17 00:00:00 2001 From: "Ian C." <108159253+ic-dev21@users.noreply.github.com> Date: Sun, 30 Nov 2025 16:47:08 -0500 Subject: [PATCH 2/5] New allowed_wh function --- pyhilo/event.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyhilo/event.py b/pyhilo/event.py index 0e7b2e9..0f935a4 100755 --- a/pyhilo/event.py +++ b/pyhilo/event.py @@ -71,6 +71,12 @@ def update_wh(self, used_wH: float) -> None: self.used_kWh = round(used_wH / 1000, 2) self.last_update = datetime.now(timezone.utc).astimezone() + def update_allowed_wh(self, allowed_wH: float) -> None: + """This function is used to update the allowed_kWh attribute during a Hilo Challenge Event""" + LOG.debug("Updating allowed Wh: %s", allowed_wH) + self.allowed_kWh = round(allowed_wH / 1000, 2) + self.last_update = datetime.now(timezone.utc).astimezone() + def should_check_for_allowed_wh(self) -> bool: """This function is used to authorize subscribing to a specific event in Hilo to receive the allowed_kWh that is made available in the pre_heat phase""" From e05b21dc345975506b889209d85fd3622e80fa52 Mon Sep 17 00:00:00 2001 From: "Ian C." <108159253+ic-dev21@users.noreply.github.com> Date: Wed, 3 Dec 2025 06:12:39 -0500 Subject: [PATCH 3/5] Update websocket.py --- pyhilo/websocket.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyhilo/websocket.py b/pyhilo/websocket.py index 7b55cf4..b5d3577 100755 --- a/pyhilo/websocket.py +++ b/pyhilo/websocket.py @@ -310,6 +310,10 @@ async def async_connect(self) -> None: raise CannotConnectError(err) from err LOG.info(f"Connected to websocket server {self._api.endpoint}") + + #Quick pause to prevent race condition + await asyncio.sleep(0.05) + self._watchdog.trigger() for callback in self._connect_callbacks: schedule_callback(callback) From 1b3412d8aad13dfda90324572f4051713bebcb37 Mon Sep 17 00:00:00 2001 From: "Ian C." <108159253+ic-dev21@users.noreply.github.com> Date: Wed, 3 Dec 2025 06:36:52 -0500 Subject: [PATCH 4/5] Update event.py --- pyhilo/event.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyhilo/event.py b/pyhilo/event.py index 0f935a4..ba7612c 100755 --- a/pyhilo/event.py +++ b/pyhilo/event.py @@ -27,7 +27,7 @@ class Event: def __init__(self, **event: dict[str, Any]): """Initialize.""" self._convert_phases(cast(dict[str, Any], event.get("phases"))) - params: dict[str, Any] = event.get("parameters", {}) + params: dict[str, Any] = event.get("parameters") or {} devices: list[dict[str, Any]] = params.get("devices", []) consumption: dict[str, Any] = event.get("consumption", {}) allowed_wH: int = consumption.get("baselineWh", 0) or 0 From f7a1545f76fde8c57ebd3d6979491f44e32c346b Mon Sep 17 00:00:00 2001 From: "Ian C." <108159253+ic-dev21@users.noreply.github.com> Date: Wed, 3 Dec 2025 17:54:56 -0500 Subject: [PATCH 5/5] Black lint --- pyhilo/websocket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyhilo/websocket.py b/pyhilo/websocket.py index b5d3577..bd23cb7 100755 --- a/pyhilo/websocket.py +++ b/pyhilo/websocket.py @@ -311,7 +311,7 @@ async def async_connect(self) -> None: LOG.info(f"Connected to websocket server {self._api.endpoint}") - #Quick pause to prevent race condition + # Quick pause to prevent race condition await asyncio.sleep(0.05) self._watchdog.trigger()