diff --git a/custom_components/hilo/__init__.py b/custom_components/hilo/__init__.py index 61069d1b..417a8519 100644 --- a/custom_components/hilo/__init__.py +++ b/custom_components/hilo/__init__.py @@ -302,6 +302,12 @@ async def _handle_websocket_message(self, event): msg_type = "challenge_details_update" elif target == "ChallengeListUpdatedValuesReceived": msg_type = "challenge_details_update" + elif target == "EventCHDetailsUpdatedValuesReceived": + LOG.debug("EventCHDetailsUpdatedValuesReceived message received") + elif target == "EventFlexDetailsUpdatedValuesReceived": + LOG.debug("EventFlexDetailsUpdatedValuesReceived message received") + elif target == "EventListUpdatedValuesReceived": + LOG.debug("EventListUpdatedValuesReceived message received") # ic-dev21 Notify listeners for listener in self._websocket_listeners: diff --git a/custom_components/hilo/manifest.json b/custom_components/hilo/manifest.json index 3ed383ce..e4b8b71f 100755 --- a/custom_components/hilo/manifest.json +++ b/custom_components/hilo/manifest.json @@ -11,6 +11,6 @@ "documentation": "https://github.com/dvd-dev/hilo", "iot_class": "cloud_push", "issue_tracker": "https://github.com/dvd-dev/hilo/issues", - "requirements": ["python-hilo>=2025.11.1"], - "version": "2025.11.4" + "requirements": ["python-hilo>=2025.12.1"], + "version": "2025.12.1" } diff --git a/custom_components/hilo/sensor.py b/custom_components/hilo/sensor.py index 9166821f..a5d10bcf 100755 --- a/custom_components/hilo/sensor.py +++ b/custom_components/hilo/sensor.py @@ -917,15 +917,28 @@ async def handle_challenge_details_update(self, challenge): event_id = self._next_events[0]["event_id"] progress = challenge.get("progress", "unknown") - baselinewH = challenge.get("baselineWh", 0) + + baseline_points = challenge.get("cumulativeBaselinePoints", []) + + if not baseline_points: + consumption = challenge.get("consumption", {}) + baseline_points = consumption.get("cumulativeBaselinePoints", []) + if baseline_points: + baselinewH = baseline_points[-1]["wh"] + else: + baselinewH = challenge.get("baselineWh", 0) + allowed_kwh = baselinewH / 1000 if baselinewH > 0 else 0 + used_wH = challenge.get("currentWh", 0) if used_wH is not None and used_wH > 0: used_kWh = used_wH / 1000 else: used_kWh = 0 + LOG.debug("handle_challenge_details_update progress is %s", progress) LOG.debug("handle_challenge_details_update baselineWh is %s", baselinewH) LOG.debug("handle_challenge_details_update used_kwh is %s", used_kWh) + LOG.debug("handle_challenge_details_update allowed_kwh is %s", allowed_kwh) if event_id in self._events: if challenge.get("progress") == "completed": @@ -945,6 +958,8 @@ async def handle_challenge_details_update(self, challenge): updated_event.appreciation(self._hilo.appreciation) if self._hilo.pre_cold > 0: updated_event.pre_cold(self._hilo.pre_cold) + if baselinewH > 0: + updated_event.update_allowed_wh(baselinewH) self._events[event_id] = updated_event self._update_next_events()