Seamless Camera Integration with Home Assistant: ONVIF and RTSP

NGC 224
DIY Smart Home Creator
Introduction
Integrating security cameras into your smart home ecosystem goes beyond simply viewing a live feed. By bringing your IP cameras into Home Assistant, you unlock powerful capabilities for local control, enhanced privacy (bypassing cloud services), and sophisticated automation based on motion detection or other triggers. This article will guide you through integrating cameras using two common protocols: ONVIF and RTSP.
Understanding ONVIF and RTSP
Before diving into the configuration, let's quickly clarify what these protocols are:
- ONVIF (Open Network Video Interface Forum): A global standard for IP-based physical security products. It allows devices from different manufacturers to communicate. Home Assistant's ONVIF integration can often automatically discover cameras, pull stream information, and even access certain camera features like motion detection events or PTZ controls if supported by the camera and the integration.
- RTSP (Real Time Streaming Protocol): A network control protocol designed for use in entertainment and communications systems to control streaming media servers. While not specifically for security devices like ONVIF, it's the standard way to request and receive a video stream from most IP cameras. You'll often use an RTSP URL to get the raw video feed.
Ideally, your camera supports ONVIF, as this simplifies discovery and provides more features. However, even if it only supports RTSP, you can still integrate the video stream into Home Assistant.
Prerequisites
Before you begin, ensure you have the following:
- Home Assistant installed and running.
- One or more IP cameras connected to your local network.
- Knowledge of your cameras' IP addresses (or hostname), and login credentials (username and password).
- Ensure your cameras' ONVIF and/or RTSP services are enabled (check your camera's web interface or manual).
- (Optional but recommended) Static IP addresses or DHCP reservations for your cameras on your router to prevent their IPs from changing.
Integrating Cameras via ONVIF (Recommended)
The ONVIF integration is the easiest way to get started if your camera supports it.
Setup Steps:
- In Home Assistant, go to Settings > Devices & Services.
- Click the + Add Integration button.
- Search for "ONVIF" and select it.
- Home Assistant may automatically discover cameras on your network. If yours appears, select it. Otherwise, choose "Configure another device".
- Enter the camera's IP address or hostname.
- Enter the camera's ONVIF username and password.
- Click Submit.
- If successful, Home Assistant will connect to the camera and show you the entities it can create (e.g., camera entity, motion sensor, PTZ controls). Select the entities you want to enable and click Finish.
- Repeat for each ONVIF camera.
ONVIF Integration Tips:
- Credentials: Use strong, dedicated credentials for ONVIF access, different from the camera's web interface login if possible.
- Discovery: If automatic discovery fails, ensure the camera is on the same subnet as Home Assistant or that your network configuration allows discovery traffic. Manually entering the IP is often more reliable.
- Firmware: Ensure your camera has the latest firmware, as this often improves ONVIF compatibility and stability.
- Multiple Streams: The ONVIF integration usually detects available streams (e.g., main stream, substream). Choose the appropriate one for performance (substream for dashboards, main stream for fullscreen).
Integrating Cameras via RTSP (Manual/Generic)
If your camera doesn't support ONVIF or you need to use a specific RTSP URL (perhaps for a secondary stream or different encoding), you can use the generic camera integration via YAML configuration.
Setup Steps:
- You'll need to find the RTSP URL for your specific camera model. This can often be found in the camera's documentation or by searching online (e.g., "[Camera Make Model] RTSP URL"). Common formats include
rtsp://<username>:<password>@<ip_address>:<port>/path/to/stream
. Ports are often 554. - Open your Home Assistant
configuration.yaml
file using the File Editor or by accessing the configuration directory. - Add an entry for the
camera
integration. If you already have one, add a new entry under it. - Use the
platform: generic
type. - Configure the camera with the RTSP URL.
Example YAML Configuration:
camera:
- platform: generic
name: My Living Room Camera
stream_source: rtsp://YOUR_USERNAME:YOUR_PASSWORD@CAMERA_IP:554/Streaming/Channels/101
still_image_url: http://CAMERA_IP/cgi-bin/snapshot.cgi
# Optional: Add authentication if required for still images
# username: YOUR_USERNAME
# password: YOUR_PASSWORD
# Optional: Specific arguments for FFmpeg (if used for streaming)
# ffmpeg_args: -pred 1
Replace placeholders like YOUR_USERNAME
, YOUR_PASSWORD
, CAMERA_IP
, and the stream_source
path with your camera's details. The still_image_url
is often used for dashboard previews when the stream isn't actively playing; find the correct URL for your camera's snapshot function.
- Save the
configuration.yaml
file. - Go to Settings > System > Restart and click Restart Home Assistant for the changes to take effect.
RTSP Integration Tips:
- Finding the URL: This is often the trickiest part. Check sites like iSpyConnect Camera Database for common formats, but always try the manufacturer's documentation first.
- Stream Paths: Cameras often have different paths for main (high resolution/frame rate) and substreams (lower resolution/frame rate). Use the substream URL for dashboard views to save performance.
- Authentication: Ensure the username and password are correctly included in the URL or configured separately if required.
- Still Image URL: A working still image URL makes dashboard loading faster. If you can't find one, Home Assistant might generate snapshots from the stream, but this uses more resources.
- FFmpeg: Home Assistant uses FFmpeg to process video streams. Ensure it's installed and working correctly in your Home Assistant environment. You can pass specific arguments using
ffmpeg_args
if needed for compatibility or performance.
Displaying Cameras in Lovelace Dashboards
Once your camera entities are set up, you'll want to display them:
- Picture Glance Card: A popular choice. Displays a still image with entity states or controls overlaid at the bottom. Tap for live view.
- Picture Entity Card: Displays a camera feed or still image as the primary visual element.
When configuring the card, select the camera entity you created. You can choose between different live view methods (e.g., Auto, Native, LL-HLS, WebRTC) depending on your Home Assistant setup and preference. LL-HLS and WebRTC generally offer lower latency but may require additional configuration or add-ons (like the official Home Assistant Cloud, or third-party solutions). Native is simpler but often has higher latency.
Best Practices for Camera Integration
- Network Security: This is paramount. Place your cameras on a dedicated VLAN if your router supports it, isolated from your main network and IoT devices. Restrict camera access to only the necessary devices (like your Home Assistant instance). Use strong, unique passwords for each camera. Disable any cloud features you don't use if your goal is local control.
- Performance: Running many high-resolution camera streams constantly can strain your Home Assistant server and network. Use substreams for dashboard views and only load the main stream when viewing fullscreen. Consider running Home Assistant on reasonably powerful hardware if you have many cameras.
- Static IPs: Always assign static IPs or DHCP reservations to your cameras. This prevents them from getting a new IP address after a router restart, which would break the integration in Home Assistant until updated.
- Storage/Recording: Home Assistant itself is not a full-featured Network Video Recorder (NVR). For continuous recording, motion-based recording, and long-term storage, consider integrating dedicated NVR software like Frigate (popular for AI object detection) or Shinobi.
- Automation: Leverage camera entities or associated sensors (like ONVIF motion alarms) in your automations. For example, turn on lights when motion is detected in a specific area, or send a notification with a snapshot.
- Monitoring: Periodically check your camera feeds and Home Assistant logs to ensure streams are stable and the integrations are working correctly.
Conclusion
Integrating your IP cameras with Home Assistant via ONVIF or RTSP brings significant advantages in terms of local control, privacy, and automation possibilities. While it might require a bit of technical configuration, especially for RTSP, the result is a more robust and integrated smart home security system that you control. Follow the setup steps and best practices outlined here to build a reliable camera monitoring solution within your Home Assistant ecosystem.

NGC 224
Author bio: DIY Smart Home Creator