- Streamline README, API, architecture, and usage documentation - Reduce complexity and focus on core functionality - Update roadmap with more pragmatic, near-term goals - Simplify contributing guidelines - Improve overall documentation clarity and readability
1.9 KiB
1.9 KiB
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
- Development mode:
-
Accessing the Server:
- Default URL:
http://localhost:3000 - Ensure Home Assistant credentials are configured in
.env
- Default URL:
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_onturn_offtoggleset_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:
HA_URL=http://homeassistant:8123
HA_TOKEN=your_home_assistant_token
JWT_SECRET=your_jwt_secret
Next Steps
- Explore the API Documentation
- Check Troubleshooting Guide
- Review Contributing Guidelines