Improve Home Assistant recognition reliability - #6
Open
booyasatoshi wants to merge 1 commit into
Open
Conversation
Author
|
Hey folks, I am following up on this PR. Is this repo being maintained or watched by anyone? Could a maintainer approve the workflow when possible so we can move on the better things? |
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.
Summary
This PR improves reliability of the Home Assistant custom integration runtime recognition path.
The changes are intentionally limited to:
custom_components/speaker_recognition/recognition.pycustom_components/speaker_recognition/stt.pyThis avoids mixing runtime reliability fixes with UI, branding, config-flow, or conversation-agent behavior changes.
What changed
Media source file resolution
The integration now resolves Home Assistant local media-source voice samples from both:
/media/<relative path>hass.config.path("media")/<relative path>It also URL-decodes the local media-source path before resolving it.
This makes voice sample training more reliable across Home Assistant OS/container layouts where the selected media file may exist under
/mediarather than only under Home Assistant's configured media path.Defensive voice sample handling
The training path now validates configured voice sample entries before using them.
It also accepts the older one-item list shape for the media selector value, while rejecting invalid, empty, or multi-file values.
This helps avoid breaking existing saved options if the selector shape changed or if older configuration data is still present.
Avoid blocking the Home Assistant event loop
Backend train and recognize calls are now run through Home Assistant's executor instead of being awaited directly in the entity's async path.
This prevents backend/client work from running directly on Home Assistant's event loop.
Training result handling
The training path no longer depends on a specific
TrainingResult.users_trainedresponse attribute.The previous logging assumed that field existed, but the installed/backend client may not expose it consistently.
Logging cleanup
Successful speaker recognition is now logged at info level instead of error level.
Actual exceptions during recognition are still logged as errors.
A recognition attempt returning no result is logged as a warning instead of an error.
Why
These changes make the Home Assistant integration more tolerant of real Home Assistant media paths, older saved selector data, backend response differences, and blocking backend calls.
They also make logs clearer by avoiding error-level messages for successful recognition.
Testing
Tested locally in Home Assistant with the speaker recognition STT proxy and conversation proxy.
Observed behavior:
speaker_recognition_detectedevents are still fired.hass.datafor conversation use.Also ran: