Create a Local Camera and Sensor Event Pipeline with Frigate, MQTT, and Home Assistant Automations
Build a local event pipeline that turns camera and sensor events into Home Assistant automations without depending on a cloud service.
Expected Outcome
A working local event pipeline that can detect motion from cameras and sensors, publish events to an MQTT broker, and trigger automations in Home Assistant.
Assumptions
- Basic understanding of Home Assistant
- Raspberry Pi or a server to run Frigate
- MQTT broker (e.g., Mosquitto) installed
- Cameras and sensors compatible with Frigate
Bill of Materials
- Raspberry Pi or server
- USB camera or IP camera
- PIR motion sensor
- MQTT broker (e.g., Mosquitto)
- Home Assistant installation
- Frigate installation files
- Wiring and connectors for sensors
Build Steps
- Set Up the MQTT Broker
Install and configure an MQTT broker to handle communication between Frigate and Home Assistant.
Changes system state: review before running
sudo apt update sudo apt install mosquitto mosquitto-clients sudo systemctl enable mosquitto sudo systemctl start mosquitto
- Install Frigate
Install Frigate on your Raspberry Pi or server to manage camera feeds and detect events.
Changes system state: review before running
docker run -d --name frigate --restart unless-stopped -v /path/to/config:/config -v /path/to/storage:/media -p 5000:5000 blakeblackshear/frigate:latest
- Configure Frigate for Your Camera
Edit the Frigate configuration file to add your camera settings.
Example pattern only. Adjust for your environment before running.
nano /path/to/config/config.yml
- Set Up the PIR Motion Sensor
Wire the PIR motion sensor to the Raspberry Pi and configure it to publish events to the MQTT broker.
Changes system state: review before running
sudo apt install python3-pip pip3 install paho-mqtt nano /path/to/motion_sensor.py
- Configure Home Assistant for MQTT
Add the MQTT integration in Home Assistant to listen for events from Frigate and the motion sensor. Manual action: Go to Configuration > Integrations in Home Assistant.
Example pattern only. Adjust for your environment before running.
Add MQTT and enter broker details
- Create Automations in Home Assistant
Set up automations in Home Assistant to respond to events published by Frigate and the motion sensor. Manual action: Go to Configuration > Automations.
Example pattern only. Adjust for your environment before running.
Create a new automation that triggers on motion detected
Validation
- Check the MQTT broker logs to ensure messages are being published.
- Verify that Frigate is detecting events and sending them to the MQTT broker.
- Test Home Assistant automations to confirm they trigger as expected.
Troubleshooting
- Check service logs before changing the design.
- Confirm ports, paths, credentials, DNS names, and container names match the guide assumptions.
Cleanup or Rollback
- Stop test services you no longer need and keep a copy of working configuration before deleting volumes or data directories.
Next Improvements
- Explore additional Frigate features like object detection.
- Integrate other sensors and devices into the pipeline.
- Create more complex automations based on multiple events.