From 2f1c0f8a815b796aafd805e3b40f7d23d29c2088 Mon Sep 17 00:00:00 2001 From: Emmanuel Levijarvi Date: Fri, 17 Oct 2025 13:37:48 -0700 Subject: [PATCH 1/2] fix: correct availableEnergyCapacity display unit in periodic_requests example The availableEnergyCapacity field represents energy in Watt-hours (Wh), not a percentage. Updated the display format from '{value}%' to '{value} Wh'. This prevents confusing output like 'Available Energy: 709.0%' which doesn't make sense for a percentage value. --- examples/periodic_requests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/periodic_requests.py b/examples/periodic_requests.py index cadbbe7..93fc35a 100755 --- a/examples/periodic_requests.py +++ b/examples/periodic_requests.py @@ -75,7 +75,7 @@ def on_device_status(status: DeviceStatus): print(f"\n--- Status Response #{status_count} ---") print(f" Temperature: {status.dhwTemperature:.1f}°F") print(f" Power: {status.currentInstPower:.1f}W") - print(f" Available Energy: {status.availableEnergyCapacity:.1f}%") + print(f" Available Energy: {status.availableEnergyCapacity:.0f} Wh") def on_device_feature(feature: DeviceFeature): """Callback receives parsed DeviceFeature objects.""" From 7df6cba8c6871f89a909166804c72fd2ed2b3b44 Mon Sep 17 00:00:00 2001 From: Emmanuel Levijarvi Date: Fri, 17 Oct 2025 14:00:00 -0700 Subject: [PATCH 2/2] fix: subscribe to device features before waiting for response in TOU example The _wait_for_controller_serial function was using the event emitter to wait for 'feature_received' events without first subscribing to device feature messages. This caused timeouts because the feature_received event is only emitted when a feature message is received and parsed. Changes: - Call subscribe_device_feature() before request_device_info() - This ensures the MQTT subscription is established before the request - Resolves 'Timed out waiting for device features' errors The pattern now matches other examples like device_feature_callback.py that successfully retrieve device features. --- examples/tou_schedule_example.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/tou_schedule_example.py b/examples/tou_schedule_example.py index 3a4d2d6..a14a0bf 100644 --- a/examples/tou_schedule_example.py +++ b/examples/tou_schedule_example.py @@ -17,8 +17,13 @@ def capture_feature(feature) -> None: if not feature_future.done(): feature_future.set_result(feature) - mqtt_client.once("feature_received", capture_feature) + # Subscribe to device feature messages first + await mqtt_client.subscribe_device_feature(device, capture_feature) + + # Then request device info await mqtt_client.request_device_info(device) + + # Wait for the response feature = await asyncio.wait_for(feature_future, timeout=15) return feature.controllerSerialNumber