A real-time dashboard for Home Assistant with WebSocket integration for live state updates.
- Real-time Updates: WebSocket connection to Home Assistant for live state changes
- Responsive Design: Works on both desktop and mobile devices
- Light Control: Toggle lights on/off with real-time feedback
- Sensor Monitoring: View temperature, humidity, power consumption, and more
- Connection Status: Visual indicator showing WebSocket connection status
Make sure to set these environment variables:
HA_URL=http://your-home-assistant-instance:8123
HA_TOKEN=your_long_lived_access_token
DASHBOARD_URL=http://localhost:3000
DASHBOARD_POSTURL=http://localhost:3000
The dashboard uses WebSocket connections to receive real-time updates from Home Assistant. When states change in Home Assistant, they are automatically reflected in the dashboard without requiring page refreshes.
- Initial Load: Fetches all current states from Home Assistant API
- WebSocket Connection: Establishes a WebSocket connection to Home Assistant
- State Subscription: Subscribes to
state_changed
events - Real-time Updates: Automatically updates the UI when states change
- Reconnection: Automatically reconnects if the connection is lost
The dashboard shows a connection status indicator:
- 🟢 Connected: WebSocket is connected and receiving updates
- 🔴 Disconnected: WebSocket is disconnected or failed to connect
⚠️ Error: Connection error occurred
# Install dependencies
pnpm install
# Run development server
pnpm dev
# Build for production
pnpm build
lib/home-assistant.ts
: Core Home Assistant client with WebSocket supporthooks/use-home-assistant.ts
: React hook for managing real-time statecomponents/connection-status.tsx
: Connection status indicator componentapp/page.tsx
: Main dashboard with real-time updates
- Check that
HA_URL
is correct and accessible - Verify that
HA_TOKEN
is valid and has the necessary permissions - Ensure Home Assistant WebSocket API is enabled
- Check browser console for connection errors
- Verify that entities exist in Home Assistant
- Check that the WebSocket connection is established
- Look for errors in the browser console
- Ensure the access token has read permissions for the entities