Fix: Enable WebSocket updates for custom Modbus register devices#215
Open
JakubRanosz wants to merge 1 commit intoUnipiTechnology:mainfrom
Open
Fix: Enable WebSocket updates for custom Modbus register devices#215JakubRanosz wants to merge 1 commit intoUnipiTechnology:mainfrom
JakubRanosz wants to merge 1 commit intoUnipiTechnology:mainfrom
Conversation
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.
Fix: Enable WebSocket updates for custom Modbus register devices
Closes #214
Problem
Modbus register devices (e.g., temperature sensors connected via RS485) were not sending value updates via WebSocket, even though:
This was a regression from Evok v2, where Modbus register updates were transmitted correctly.
Root Cause
The
Registerclass was missing the necessary infrastructure to participate in the event notification system:check_new_data()method to detect value changesAs a result, the periodic scan loop would read register values but never detect changes or notify WebSocket clients.
Solution
This PR adds the missing event notification infrastructure to the
Registerclass:Changes Made
Added value caching (
_cached_value)Implemented
check_new_data()methodTruewhen a change is detectedRegistered Register devices as eventable
self.__register_eventable_device(_reg)inparse_feature_register()Updated
valuepropertyTechnical Details
The fix follows the same pattern used by other eventable devices (
DigitalInput,DataPoint, etc.):