Fix ezo parsing - #4792
Merged
Merged
Conversation
- Only proceed if first byte is 1 (previous code would proceed nevertheless in case of EZO_CALIBRATION commands) - Truncate returned value only for EZO_READ commands (previous code would truncate it always, making parsing impossible)
Temperature-compensated readings (EZO_T) behave like regular commands, so they need the same parsing.
|
Hey there @ssieb, mind taking a look at this pull request as it has been labeled with an integration ( |
jesserockz
approved these changes
May 9, 2023
Member
There was a problem hiding this comment.
Can't test it, but code looks fine.
Merged
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What does this implement/fix?
The current parsing of the EZO sensor had a few issues that wouldn't make them work. Namely:
This is tested against both a pH and ORP EZO sensors. I've carefully reviewed all EZO datasheets, and they all follow the same pattern, so this code should work with every EZO sensor available at time of writing. The only caveat is the RGB EZO sensor which, by nature, on EZO_READ returns 3 comma-separated values (R,G,B). The current implementation only returns the "R" component. Support for the RGB sensor entails a breaking change, where "EZO_READ" returns an array of values. I'd be happy to implement such a change, but didn't want to introduce a breaking change at this stage.
Types of changes
Related issue or feature (if applicable): N/A
Pull request in esphome-docs with documentation (if applicable): N/A (no documentation updates required)
Test Environment
Example entry for
config.yaml:Typical use case reading the EZO_CALIBRATION status:
Without this patch, the "on_calibration" callback is never invoked, due to parsing issues.
Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed: