feat: Command Response API WebSocket plumbing#409
Conversation
|
Same problems as before, including the fact the PR tries to do far too much at once. The potential for issues/breaks is astronomical. (Same goes for the Z2M PR.) |
|
understood. Will revert to bare-minimum; and replace with the zigbee2mqtt (backend) preferred MQTT topics approach in discussion. Thanks for your patience and guidance. |
|
This pull request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Route device commands through /request/set and /request/get topics and handle responses on /response/set and /response/get with z2m_transaction correlation. - Add CommandResponse type for transaction responses - Add callback infrastructure in WebSocketManager (register, unregister, timeout handling, transaction ID generation) - Intercept /response/* messages to prevent device state corruption - Extract useDeviceCommands hook for centralized command routing - Update Exposes, DashboardItem, GroupMembers to use new topics - Suppress "request superseded" error toasts for sleepy devices - Update mock WS server to support new topic format
|
@Nerivec This has been paired back to the bare minimum - no new device mocks/tests and no visual feedback. Just the WebSocket plumbing for the Command Response API:
8 files, ~330 lines. (Visual feedback (StatusIndicator, retry buttons, etc.) will come in a follow-up PR once this is in):
The bulk of the production change is WebSocketManager.ts (+108) - the callback infrastructure. The rest is small: new Remains as 'draft' until zigbee2mqtt backend changes are merged. |
|
This pull request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Summary
WebSocket plumbing for the Zigbee2MQTT Command Response API. Routes device commands through the new
/request/set|gettopics and handles responses on/response/set|getwithz2m_transactioncorrelation.Depends on: Backend PR #30774 (Command Response API)
Related: Backend feature request #30679
Full implementation with visual feedback: transaction-response-api branch
Changes
New Files
src/hooks/useDeviceCommands.ts— Centralised hook for device set/get routing via new topicsModified
/response/*message interceptionCommandResponsetype definitionuseDeviceCommandshook/request/setWhat this PR does NOT include (deferred to follow-up)
How it works
{ieee}/request/setand{ieee}/request/getinstead of{ieee}/setand{ieee}/get/response/setand/response/getmessages (preventing device state corruption)z2m_transaction, with automatic timeout cleanupTest Plan
/request/set|get(confirmed via logs)/response/set|get