Lesson 8: From Detection to Action (AI Camera Triggers a Smart Bulb via Home Assistant)
In this lesson, you'll connect your AI-powered camera system from Month 3 to your smart home—transforming visual detection into real-world automation.
Last month, you built an object detection model that could identify when a person appeared in a specific zone of your Pi camera feed. Your original code likely looked like this:
if person_detected:
GPIO.output(led_pin, True)
else:
GPIO.output(led_pin, False)
Today, you’ll upgrade this system. Instead of toggling a basic LED, you'll send a web request to Home Assistant—activating a smart bulb, smart plug, or scene when a person is detected.
Here's What You’ll Do:
- Keep your existing AI detection code intact
- Replace the GPIO.output() line with a webhook or REST API call to Home Assistant
- Use that call to toggle an RGB bulb, activate a plug, or run a scene (like "Movie Time") when you're detected on the couch
When you leave the couch and no person is detected for 60 seconds, the lights will turn off—fully automated presence-based control using nothing but a camera and code.
Example Experience:
- You sit on the couch → Camera detects you
- Home Assistant receives the signal → Activates your lighting scene
- You leave the couch → Lights turn off after a delay
We provide the full code snippet and Home Assistant webhook setup instructions below the video. You’ll learn how to safely send a web request using Python to your Home Assistant instance, and how to create a corresponding Webhook trigger in an automation.
Creative Bonus Challenge – AI-Driven Scene Automation:
Push the concept further with layered automations:
- When you sit down → RGB lights fade into warm tones
- After 5 minutes → A fan turns on
- When you leave → All lights turn off and the fan shuts down
This is your first step toward building a true AI-powered home assistant—no buttons, no voice commands, just intelligent, real-time environmental control based on what your camera sees.
By the End of This Lesson, You’ll Know How To:
- Reuse your AI camera object detection model from Month 3
- Replace GPIO LED triggers with Home Assistant Webhooks
- Trigger lights, plugs, and scenes based on real-time visual input
- Design intelligent automations using presence detection
Coming up next: we’ll turn this same AI system into a full-fledged security system with alerts, snapshots, and smart home defenses.