Skip to content

Add Web API endpoints for StackChan state and wakeword management#18

Merged
74th merged 1 commit intomainfrom
feat/web-api
Mar 11, 2026
Merged

Add Web API endpoints for StackChan state and wakeword management#18
74th merged 1 commit intomainfrom
feat/web-api

Conversation

@74th
Copy link
Owner

@74th 74th commented Mar 11, 2026

This pull request adds a REST API to the stackchan_server for managing and monitoring StackChan devices, and introduces internal state tracking for connected clients. The main changes include new API endpoints for listing, inspecting, and controlling StackChan devices, as well as enhancements to connection management and state synchronization.

REST API additions:

  • Added new REST API endpoints to stackchan_server/app.py for:
    • Listing all connected StackChan devices (/v1/stackchan)
    • Retrieving the state of a specific StackChan (/v1/stackchan/{stackchan_ip})
    • Triggering the wakeword event on a StackChan via API (/v1/stackchan/{stackchan_ip}/wakeword)
    • Sending a text-to-speech request to a StackChan (/v1/stackchan/{stackchan_ip}/speak)
    • Introduced StackChanInfo and SpeakRequest Pydantic models for request/response validation [1] [2] [3]

Connection and state management improvements:

  • Implemented a _proxies dictionary in StackChanApp to track active WebSocket connections by client IP, enabling the new REST endpoints and device management features
  • Enhanced connection handling to automatically disconnect any existing connection from the same IP before accepting a new one, ensuring only one active connection per device [1] [2]

StackChan state tracking and control:

  • Added current_state property and internal state tracking to WsProxy, synchronizing the firmware state with the server whenever a state event is received [1] [2]
  • Added trigger_wakeword method to WsProxy to allow the REST API to simulate a wakeword event programmatically

@74th 74th merged commit 79d47e3 into main Mar 11, 2026
1 check passed
@74th 74th deleted the feat/web-api branch March 11, 2026 10:32
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.

1 participant