Add WebSocket support for real-time dashboard updates#812
Merged
Conversation
15 tasks
There was a problem hiding this comment.
Pull Request Overview
This PR introduces WebSocket support to enable real-time dashboard updates, replacing polling-based approaches for device status and online state monitoring. The implementation provides automatic reconnection with exponential backoff, connection status notifications, and event-driven data synchronization.
Key Changes
- Added WebSocket infrastructure with automatic reconnection and ping mechanisms
- Converted device list and online status from polling to real-time WebSocket updates
- Implemented connection status UI with toast notifications
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/util/websocket-url.ts | Utility function to build WebSocket URLs with protocol conversion |
| src/util/websocket-collection.ts | Generic WebSocket collection manager for real-time data updates |
| src/util/connection-status.ts | Connection status UI with toast notifications |
| src/esphome-main.ts | Initialize connection status on app startup |
| src/devices/devices-list.ts | Updated to use new refresh mechanism |
| src/api/websocket.ts | Core WebSocket client with reconnection and ping support |
| src/api/online-status.ts | Converted from polling to WebSocket-based updates |
| src/api/index.ts | Refactored to use shared WebSocket URL builder |
| src/api/devices.ts | Converted device management to WebSocket events |
| src/api/dashboard-events.ts | Event type definitions for WebSocket communication |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
balloob
approved these changes
Sep 26, 2025
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.
Add WebSocket support for real-time updates
This PR adds WebSocket support to the ESPHome dashboard frontend, working in conjunction with esphome/esphome#10893 to provide real-time updates instead of polling.
Changes
WebSocket Infrastructure
DashboardWebSocketclass (src/api/websocket.ts) with:Real-time Collections
createWebSocketCollectionutility (src/util/websocket-collection.ts) for managing real-time datasrc/api/devices.ts)src/api/online-status.ts)Connection Status UI
src/util/connection-status.ts)Event Types Supported
initial_state- Initial device and ping status on connectionentry_added,entry_removed,entry_updated- Device lifecycle eventsentry_state_changed- Device online/offline status changesimportable_device_added,importable_device_removed- mDNS discovered devicesping,pong- WebSocket keepaliveBenefits
/devicesand/pingendpointsTesting
Related