feat: add update frequency and operation mode parameters to MQTT client - #10
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds support for configuring MQTT client update frequency and operation mode when creating a VRM MQTT client. The implementation adds new parameters to both the VRMMQTTClient class and the get_mqtt_client_for_installation method, with safety bounds for update frequency (0-300 seconds).
Changes:
- Added
update_frequencyandoperation_modeparameters toVRMMQTTClient.__init__with validation logic - Updated
get_mqtt_client_for_installationmethod signature to accept these parameters - Imported
OperationModefromvictron_mqttin both files
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| victron_vrm/mqtt.py | Added new parameters to VRMMQTTClient constructor with update_frequency clamping logic and passed them to parent VictronMQTTHub class |
| victron_vrm/client.py | Added import for OperationMode and updated get_mqtt_client_for_installation method signature with new parameters and documentation |
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.
This pull request adds support for configuring the MQTT client's update frequency and operation mode when creating a VRM MQTT client, providing more flexibility for users of the library. The changes also ensure that the update frequency is safely bounded between 0 and 300 seconds.
MQTT Client Configuration Enhancements
update_frequencyandoperation_modeparameters to both theVRMMQTTClientconstructor and theget_mqtt_client_for_installationmethod inclient.py, allowing callers to specify how often updates are received and the operational mode of the MQTT client. [1] [2]update_frequencyvalue is clamped between 0 and 300 seconds for safety and reliability.client.pyandmqtt.pyto include the newOperationModetype fromvictron_mqtt, supporting the new parameter. [1] [2]update_frequency_secondsandoperation_mode) to the baseVictronMQTTHubclass inVRMMQTTClient, ensuring the configuration is applied at the hub level.