Skip to content

Conversation

@zehnm
Copy link
Contributor

@zehnm zehnm commented Dec 17, 2025

Add voice-assistant entity support.

The binary protobuf audio chunk messages are exposed as an easy to use voice-stream session in integration drivers.
A minimal example is included in examples/voice.py.

Breaking Changes

  • Enhance entity command handler with WS client connection parameter in CommandHandler callback and Entity.command method to allow clients to send back event messages.
    • The implementation is currently backward-compatible but will be removed in a future release.

Changed

  • Remove logging in Entities.get method if entity doesn't exist. This could lead to excessive logging in some integrations.

Required for: unfoldedcircle/integration-androidtv#120
Closes #37

zehnm added 17 commits November 24, 2025 23:35
workaround for missing session_id & AudioConfiguration information
- For abnormal terminations (timeout, remote abort, local abort, error),
  raise specific exceptions from the iterator.
- expose metadata about the end (reason, error) via properties for post-
  loop inspection.
- Exception hierarchy:
  - `VoiceSessionClosed(Exception)` base with optional fields (reason, error).
  - `VoiceSessionTimeout(VoiceSessionClosed)`
  - `VoiceSessionRemoteEnd(VoiceSessionClosed)`
  - `VoiceSessionLocalEnd(VoiceSessionClosed)`
  - `VoiceSessionError(VoiceSessionClosed)`
- End reason type:
  - `VoiceEndReason` Enum: `NORMAL`, `TIMEOUT`, `REMOTE`, `LOCAL`, `ERROR`
Verify AudioConfiguration in session from voice_start command.
This requires firmware 2.8.2 or newer.
Simplify, too many dicts keeping track of a voice session!
Enforce that there's only one session per voice-assistant entity.
Pass the WS connection as an optional command parameter to the client.
This allows the client to send directed WS events back. Otherwise, the
only option is to use event broadcasts to all connected clients.
Implementation is backward compatible to existing clients without the
new websocket parameter in the CommandHandler callback, or extending a
concrete Entity class.

Import cleanup to avoid circular imports through the ucapi definition.
@zehnm zehnm self-assigned this Dec 17, 2025
@zehnm zehnm changed the title Feat/voice Add voice-assistant entity and audio-stream support Dec 17, 2025
@zehnm zehnm marked this pull request as ready for review December 17, 2025 11:37
@zehnm zehnm merged commit f10e1de into main Dec 17, 2025
4 checks passed
@zehnm zehnm deleted the feat/voice branch December 17, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support new voice_assistant entity and receiving microphone audio-stream

2 participants