Lesson 9: Smarter Scenes with Smarter Vision (Advanced AI Camera Triggers with Multiple Zones & Scenes)
Today’s lesson takes your AI-powered smart home system to a new level by introducing zone-based automation. Instead of simply reacting to presence, your camera will now respond differently depending on where a person is within the frame—creating context-aware automation using computer vision.
What You’ll Do:
- Divide the camera frame into zones (like left vs. right side of a couch)
- Trigger different Home Assistant scenes based on where someone is detected
- Reset to an idle state when no one is detected
Example Setup:
- Left side of the couch → Activates “Relax Scene” (e.g., warm lights + ambient music)
- Right side of the couch → Activates “Focus Scene” (e.g., bright lights + white noise)
- No one present → Resets to “Idle Mode” (turn off lights, pause audio)
How It Works:
You’ll build on your existing person detection code from Month 3. Here's a basic concept in Python:
if person_detected:
if x_center < frame_width / 2:
trigger_scene("Relax")
else:
trigger_scene("Focus")
else:
trigger_scene("Idle")
- x_center is the horizontal midpoint of the detected person’s bounding box
- frame_width is the full width of the camera image
- trigger_scene() is a function that sends a webhook or REST API request to Home Assistant (example code is linked below the video)
This creates zone-aware automation, where your smart home responds based on where you are—not just if you’re there.
Advanced Ideas (Optional):
Want to go beyond just left/right detection? Try:
- Detecting number of people in the frame to trigger solo or group scenes
- Adding time conditions (e.g., only trigger “Relax Mode” if after sunset)
- Using facial expression or posture detection to create custom modes like “Sleepy Mode”
Each upgrade is just a layer on top of what you've already built.
Creative Bonus Challenge – Dual User Mode:
Build a socially aware smart system that changes based on how many people are in the room:
- If one person → Trigger “Solo Mode”
- If two people → Trigger “Shared Scene,” such as:
- Both RGB bulbs turn on
- Room temperature scene activates
- Cozy lights and music start playing via Spotify integration
- (Bonus) Add a 30-second delay before activating, to confirm both people are staying
This brings human context to your AI vision system—like having a home that knows who is there and how to respond.
By the End of This Lesson, You’ll Know How To:
- Add zone-based logic to your existing AI camera detection system
- Trigger different Home Assistant scenes based on location within the camera’s view
- Build more intelligent, nuanced smart environments
- Extend your automation to support multiple users or behaviors
Coming up next: your capstone project! You’ll combine everything from the past lessons into a unified smart home experience.