Usage Guide
This guide explains how to use the Home Assistant MCP Server for basic device management and integration.
Basic Setup
- Starting the Server:
- Development mode:
bun run dev
-
Production mode:
bun run start
-
Accessing the Server:
- Default URL:
http://localhost:3000
- Ensure Home Assistant credentials are configured in
.env
Device Control
REST API Interactions
Basic device control can be performed via the REST API:
// Turn on a light
fetch('http://localhost:3000/api/control', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
entity_id: 'light.living_room',
command: 'turn_on',
parameters: { brightness: 50 }
})
});
Supported Commands
turn_on
turn_off
toggle
set_brightness
Supported Entities
- Lights
- Switches
- Climate controls
- Media players
Real-Time Updates
WebSocket Connection
Subscribe to real-time device state changes:
const ws = new WebSocket('ws://localhost:3000/events');
ws.onmessage = (event) => {
const deviceUpdate = JSON.parse(event.data);
console.log('Device state changed:', deviceUpdate);
};
Authentication
All API requests require a valid JWT token in the Authorization header.
Limitations
- Basic device control only
- Limited error handling
- Minimal third-party integrations
Troubleshooting
- Verify Home Assistant connection
- Check JWT token validity
- Ensure correct entity IDs
- Review server logs for detailed errors
Configuration
Configure the server using environment variables in .env
:
Next Steps
- Explore the API Documentation
- Check Troubleshooting Guide
- Review Contributing Guidelines