A complete smart home automation system built with Flask, ESP32, and modern web technologies. Control lights, monitor cameras, interact with voice commands, and integrate with Spotify - this is controlled by web interface. The final objective of this project is to control most devices in the house using either voice commands or the phone while minimizing the amount of data sent to companies.
β οΈ Development NoticeThis project is currently under active development as a learning platform for:
- Server management and web service deployment
- Hardware-software integration with IoT devices
- Real-time communication between web interfaces and microcontrollers
- RESTful API design and implementation
- Network protocols and client-server architecture
Features may change, and bugs are expected. Contributions, suggestions, and feedback are highly appreciated as part of the learning process!
- Web-based control panel for all connected lights
- ESP32 auto-registration - lights appear automatically when configured
- Real-time state synchronization between web and hardware
- Master controls - turn any light on/off from website.
- Live camera feeds via MJPEG streams
- Motion detection alerts with timestamp tracking
- Multi-camera support with easy configuration
- Responsive grid layout for viewing multiple cameras
- Voice command processing using Google Speech Recognition. (temporary)
- Text-to-Speech responses via Google TTS. (temporary)
- Spotify integration - play, pause, resume music by voice
- Smart home queries - time, date, camera status
- Extensible command system
- Voice-controlled playback - search and play songs (Bugg refering to HTTP not having automatic permision to open microphone)
- Multi-device support - works with any Spotify Connect device (Curretly buggs with required cookies)
- Playback control - play, pause, resume
- Clean, modern chat interface
- Integration ready for AI services.
- Flask - Python web framework
- Flask-CORS - Cross-origin resource sharing
- SpeechRecognition - Voice input processing
- gTTS - Google Text-to-Speech (temporary)
- Spotipy - Spotify Web API integration
- PyDub - Audio file processing
- Pure HTML/CSS/JavaScript - No framework dependencies
- Responsive design - Works on mobile and desktop
- Modern UI - Gradient backgrounds, smooth animations
- Real-time updates - Automatic state synchronization
- ESP32 microcontrollers
- WiFi connectivity with auto-configuration
- Relay modules for light control
- Reset functionality - 5-second hold to factory reset
- Python 3.8 or higher
- Flask and dependencies
- LAN connectivity
- Microphone (for voice features)
- ESP32 development board
- Arduino IDE with ESP32 support
- Required libraries:
- WiFi
- WebServer
- HTTPClient
- ArduinoJson
- Preferences
- nvs_flash
- Spotify Premium account
- Spotify Developer App credentials
Access the web interface at http://YOUR_SERVER_IP:5000 or by opening the HTML files directly.
Navigation:
- / - Home dashboard
- /camaras - Camera feeds and motion detection
- /luces - Light control panel
- /IA - AI assistant chat interface
- Flash the ESP32 code to your device
- Power on the ESP32
- Connect to "ESP32-Setup" WiFi network
- Open http://192.168.4.1 in your browser
- Enter WiFi credentials, light name, and location
- Save - the light will appear automatically in the web interface
Hold the boot button (GPIO 0) for 5 seconds to completely erase all configuration and return to setup mode.
| Command | Action |
|---|---|
| "Reproduce [canciΓ³n]" | Play a song on Spotify |
| "Pausa la mΓΊsica" | Pause playback |
| "ContinΓΊa la mΓΊsica" | Resume playback |
| "ΒΏQuΓ© hora es?" | Get current time |
| "ΒΏQuΓ© dΓa es hoy?" | Get current date |
| "Estado de las cΓ‘maras" | Get motion detection status |
| "Hola" | Greeting |
| "Gracias" | Thank you |
GET /api/lights - Get all lights
GET /api/lights/<id> - Get specific light
POST /api/lights/register - Register new ESP32 light
POST /api/lights/<id>/toggle - Toggle light state
POST /api/lights/<id>/heartbeat - ESP32 status update
POST /api/lights/sync - Sync all lights state
DELETE /api/lights/<id> - Delete a light
POST /api/process_voice - Process audio and return response
GET /api/audio/<filename> - Serve generated audio files
GET /health - Server status
casa-smart-home/
βββ server.py # Main Flask server
βββ esp32_light_controller.ino # ESP32 firmware
βββ index.html # Home page
βββ camaras.html # Camera monitoring page
βββ luces.html # Light control page
βββ IA.html # AI assistant page
βββ lights_state.json # Persistent light state storage
βββ README.md # This file
- Change default ESP32 AP password ("12345678")
- Use HTTPS in production
- Implement authentication for web interface
- Secure Spotify credentials
- Use environment variables for sensitive data
- Keep firmware updated
- Verify WiFi credentials are correct
- Check signal strength
- Hold boot button for 5 seconds to reset
- Check serial monitor for error messages
- Verify server is running
- Check ESP32 serial monitor for connection status
- Ensure ESP32 and server are on same network
- Try reloading the lights page (π Actualizar button)
- Check microphone permissions
- Verify internet connection (Google API required) (temporary)
- Check browser console for errors
- Ensure audio format is supported
- Verify Spotify Premium account
- Check API credentials
- Ensure redirect URI matches exactly
- Open Spotify app on a device for playback
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.