Skip to content

Add Android Assist VAD timing settings#6895

Draft
lextiz wants to merge 4 commits into
home-assistant:mainfrom
lextiz:codex/android-assist-vad-settings-green-20260524
Draft

Add Android Assist VAD timing settings#6895
lextiz wants to merge 4 commits into
home-assistant:mainfrom
lextiz:codex/android-assist-vad-settings-green-20260524

Conversation

@lextiz
Copy link
Copy Markdown

@lextiz lextiz commented May 24, 2026

Adds Assist VAD silence and timeout settings to Android voice input.

Copilot AI review requested due to automatic review settings May 24, 2026 18:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jpelgrom jpelgrom marked this pull request as draft May 25, 2026 20:14
@jpelgrom jpelgrom marked this pull request as ready for review May 25, 2026 20:14
@jpelgrom jpelgrom closed this May 25, 2026
@jpelgrom jpelgrom reopened this May 25, 2026
@jpelgrom
Copy link
Copy Markdown
Member

CI actions were stuck, which is why I drafted/undrafted and closed/reopened this PR. Now available so we can get started with review :)

Comment on lines +183 to +185
suspend fun setAssistVadSilenceSeconds(seconds: Double?)

suspend fun setAssistVadTimeoutSeconds(seconds: Double?)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not exposes Double here and use Duration instead

Suggested change
suspend fun setAssistVadSilenceSeconds(seconds: Double?)
suspend fun setAssistVadTimeoutSeconds(seconds: Double?)
suspend fun setAssistVadSilence(duration: Duration?)
suspend fun setAssistVadTimeout(duration: Duration?)

You'll need to adjust the rest of the codebase. Whenever we can we should avoid primitive types to represent time, in this specific case only the persistent layer and serialization layer should know what to do with the Duration object. it allow for instance to store milliseconds and send something like hours if we want, without having to change the whole chain of call.

Comment on lines +48 to +50
fun Double.toAssistVadSecondsString(): String = BigDecimal.valueOf(this).stripTrailingZeros().toPlainString()

fun Double?.toAssistVadSecondsInput(): String = this?.toAssistVadSecondsString().orEmpty()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use string here? While migrating to Duration I invite you to migrate to Long if you store the milliseconds or properly document this choice of design.

Comment on lines +38 to +46
fun String.normalizedAssistVadSecondsInputOrNull(): String? {
val normalized = replace(',', '.')
if (normalized.isEmpty()) return normalized
if (normalized.count { it == '.' } > 1) return null
return normalized.takeIf { it.all { char -> char.isDigit() || char == '.' } }
}

fun String?.toAssistVadSecondsOrNull(): Double? =
this?.normalizedAssistVadSecondsInputOrNull()?.toDoubleOrNull()?.takeIf { it.isFinite() && it > 0.0 }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feel wrong and probably at the wrong place.

_uiState.update { it.copy(isTestingWakeWord = testing, wakeWordDetected = false) }
}

fun onVadSilenceSecondsChanged(value: String) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should enforce the logic onto the fields and expose to the user when the value are not valid (if they can set an invalid value).


Spacer(modifier = Modifier.height(HADimens.SPACE2))

SectionHeader(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to regenerate the screenshot tests

@TimoPtr TimoPtr marked this pull request as draft May 26, 2026 06:39
@TimoPtr
Copy link
Copy Markdown
Member

TimoPtr commented May 26, 2026

Update the description of the PR to match the official template and add screenshots or even video of the new usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants