-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sen5x: add TPS & PM number concentration #6694
Open
CodeInPolish
wants to merge
8
commits into
esphome:dev
Choose a base branch
from
CodeInPolish:enh_sen5x_with_pm_number_concentration
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8fc28a5
enh(sen5x): add TPS & PM number concentration
CodeInPolish 69534e2
enh(sen5x): reduce timeout of extra PM reading
CodeInPolish 1413c34
rev(sen5x): remove new entities from tests5 & tests11.5
CodeInPolish 095dedc
ref(sen5x): consolidate test configs
CodeInPolish 5848d0e
ref(sen5x): check invalid meas before scaling it
CodeInPolish 7428b4b
ref(sen5x): check humidity, voc & nox are signed ints
CodeInPolish c075183
feat(sen5x): FSM for read commands arbitration
CodeInPolish 9c8eb69
enh(sen5x): use std units for pm_count
CodeInPolish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no guarantee that this will be enough time. Ideally the component would be changes to have a small state machine and run through the stage one at a time in
loop
once triggered by theupdate
function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's very true. Wouldn't a loop in the update function block the main event loop though?
Another approach I was testing was to perform only one reading (either pm with rh/t/nox/vox or full pm) per update.
If
get_pm_number_concentration_and_tps_
was true, we would need to halve the user specifiedupdate_interval
in the setup withset_update_interval
and while it was reporting the correct update interval when dumping the config, the sensor was still exporting entities with the original period (i.e. halving it didn't affect the actual period betweenupdate
calls).I brainstormed a little and came up with another solution:
this->set_timeout(10)
if the state isn'tupdate_measured_values_done
update_measured_pm_()
function (from the helper function) when the FSM is inupdate_measured_values_done
state and reset the FSM toidle
inupdate_measured_pm_()
This would ensure
update_measured_values_()
has had enough time to complete without blocking the main event loop with a loop. What are your thoughts on this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, in the loop state machine you can check the current time against the start time of the last state change and when enough time has passed, you read the data and publish. No delays and timeouts are needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jesserockz thank you. I misunderstood what you said earlier (and also didn't know
loop
was still triggered forPollingComponent
)I went ahead and implemented the brainstormed solution, because it's less code and less complicated than a full blown FSM for all the tasks to perform. If that's not an acceptable solution, let me know.