Fix device info timeout in TOU schedule example#22
Merged
Conversation
…s 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.
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
tou_schedule_example.pywas consistently timing out when trying to get the controller serial number, showing this error:Root Cause
The
_wait_for_controller_serialfunction was using the event emitter to wait forfeature_receivedevents without first subscribing to device feature messages:The
feature_receivedevent is only emitted when a device feature message is received and parsed by a subscribed handler. Without the subscription, the MQTT client never receives the response messages.Solution
Fixed the function to properly subscribe to device feature messages before making the request:
This ensures:
feature_receivedevent is properly emittedVerification
device_feature_callback.pyevent_emitter_demo.py) is correctly implementedType of Change
Impact
This fix ensures the TOU schedule example works correctly and can successfully retrieve the controller serial number needed for TOU operations.