Be Smart, Go Local.

Integrating Sonoff CAM-PT2 In Home Assistant via Frigate

Guide for integrating the new Sonoff Pan/Tilt camera model CAM-PT2 in Home Assistant via the ONVIF integration or directly in Frigate.

About the Sonoff CAM-PT2

The Sonoff CAM-PT2 is a new, affordable, and smart indoor pan-tilt security camera designed for home use. It records in 1080P Full HD and supports a wide field of view through pan tilt motion, about 340° horizontally and 180° vertically.

It includes smart night vision modes with two invisible 940 nm infrared LEDs for dark visibility and white LEDs that switch on for color mode when needed. There is two way audio with microphone and speaker, preset points for up to six angles, motion detection zones, AI human detection, local storage via microSD up to 128 GB, and optional cloud storage. Power input is 5V 2A via USB-C, lens aperture is f/2.0, and it connects through 2.4 GHz Wi-Fi to your home network.

Sonoff CAM-PT2 Pan Tilt Camera Hero Image

This cam is very affordable, with a price tag of about $25 on their official Sonoff Webstore. It’s a great little PTZ cam that can be added to Home Assistant and Frigate via ONVIF. In this guide, I will show you how to do just that.

Integrating Sonoff CAM-PT2 in Home Assistant

Sonoff officially supports integration of the CAM-PT2 into Home Assistant through the ONVIF integration. The process is straightforward, but you need to prep the camera before adding it. This includes updating the firmware and enabling ONVIF support in the camera settings with the eWelink app. Here’s a step by step guide:

Sonoff CAM-PT2 Pan Tilt Camera Added to Home Assistant via ONVIF
Sonoff CAM-PT2 Pan Tilt Camera Added to Home Assistant via ONVIF
  1. Open the eWeLink app
  2. Go to Device Settings → Current Version → Firmware Update
  3. Click Confirm and wait for the upgrade to finish
  4. Go to Device Settings → More Settings → ONVIF/RTSP
  5. Toggle the option to enable streaming
  6. Note down the IP address of the camera, the ONVIF port, username, and password
  7. You can also change the Username and Password
  8. Save, done.

Before you add the integration in Home Assistant, you might want to enable motion detection, human detection, smart tracking in the app. With these toggled on, you will be able to get motion events in Home Assistant via ONVIF. Open Home Assistant and add the integration:

  1. In Home Assistant, go to Settings → Devices & Services → Add Integration.
  2. Search for ONVIF in the integration list.
  3. Allow Home Assistant to automatically discover the camera on your local network OR
  4. Enter the IP address, port, and login credentials manually.
  5. After setup, Home Assistant will create entities for the video feed and detection sensors.
  6. Bind a static IP address to the camera in your router
  7. Done

Controlling PAN and TILT Through Home Assistant

The ONVIF integration adds a service [onvif.ptz] to your camera that you can use to pan or tilt the Sonoff CAM-PT2 through Home Assistant. This action can be called through automations, scripts or simply used in dashboards and camera cards.

For example, the Advanced Camera Card supports PTZ and so much more, it’s like the Swiss knife of camera control in Home Assistant. You can also achieve a similar functionality with built-in Home Assistant cards. Here’s an example code for a picture glance card in HA:

type: picture-glance
camera_image: camera.sonoff_cam_pt2_mainstream
camera_view: live
entities:
  - entity: camera.sonoff_cam_pt2_mainstream
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.sonoff_cam_pt2_mainstream
        pan: LEFT
        speed: 1
        distance: 0.3
        move_mode: ContinuousMove
    name: Pan Left
    show_state: false
    icon: mdi:arrow-left
    show_icon: true
  - entity: camera.sonoff_cam_pt2_mainstream
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.sonoff_cam_pt2_mainstream
        tilt: UP
        speed: 1
        distance: 0.3
        move_mode: ContinuousMove
    name: Tilt Up
    icon: mdi:arrow-up
  - entity: camera.sonoff_cam_pt2_mainstream
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.sonoff_cam_pt2_mainstream
        tilt: DOWN
        speed: 1
        distance: 0.3
        move_mode: ContinuousMove
    name: Tilt Down
    icon: mdi:arrow-down
  - entity: camera.sonoff_cam_pt2_mainstream
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.sonoff_cam_pt2_mainstream
        pan: RIGHT
        speed: 1
        distance: 0.3
        move_mode: ContinuousMove
    name: Pan Right
    icon: mdi:arrow-right
    show_icon: true

Integrating Sonoff CAM-PT2 in Frigate

If you are a Frigate user, you probably already know the drill. You need to add the stream in Frigate’s config, and re-stream to prevent duplicate connections to the camera. Unlike the Aqara G5 Pro, which required a separate stream to fetch audio, the Sonoff CAM-PT2 uses the same stream to also publish audio. Here is a basic, minimal configuration example:

mqtt:
  enabled: false
go2rtc:
  streams:
    cam_pt2: rtsp://SmartHomeScene:12345678@192.168.0.18:554/av_stream/ch0
cameras:
  cam_pt2:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/cam_pt2
          roles:
            - detect #or record etc.
version: 0.16-0

This configuration sets up the Sonoff CAM-PT2 stream in Frigate through go2rtc. The camera’s RTSP feed is first defined under the go2rtc: streams section, which allows the camera to be pulled once from the network and then restreamed locally. By doing this, the camera and local network are not burdened with multiple direct connections, and the restream can be used by both Frigate and Home Assistant without extra load on the device.

Then, in the camera block, Frigate is pointed to the local restream instead of the original camera address. This setup ensures that all processing and viewing requests go through go2rtc, keeping the camera itself from being accessed multiple times. By centralizing the feed in this way, you maintain a more stable connection, reduce network overhead, and make it easier to share the same video stream with Home Assistant or other services without introducing duplicate connections.

Sonoff CAM-PT2 Pan Tilt Camera Added to Home Assistant via Frigate
Sonoff CAM-PT2 Basic Frigate Config

However, to also get PTZ control through Frigate, we also need to add the ONVIF configuration and allow a direct connection between Frigate and the Sonoff CAM-PT2. Here’s how that looks like:

mqtt:
  enabled: false
go2rtc:
  streams:
    cam_pt2: rtsp://SmartHomeScene:12345678@192.168.0.18:554/av_stream/ch0
cameras:
  cam_pt2:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/cam_pt2
          roles:
            - detect #or record etc.
    onvif:
      host: 192.168.0.18
      port: 80
      user: SmartHomeScene
      password: "12345678"
version: 0.16-0

Summary

The Sonoff CAM-PT2 works seamlessly in both Home Assistant and Frigate, giving you live video, motion and human detection events, as well as PTZ control in either integration. Home Assistant provides easy access to entities for dashboards and automations, while Frigate takes care of local restreaming and optional object detection without stressing the camera with multiple connections.

Furthermore, blocking the internet connection in my firewall has no effect on the Sonoff CAM-PT2. It continues to operate locally without any issue. Which means, no cloud dependency whatsoever. If you like this cam, I think its price is very hard to beat. Here’s where you can get it:

Sonoff CAM-PT2 Pan Tilt Camera Where to Buy

Sonoff CAM-PT2

Wi-Fi 2.4GHz

1080P, Infrared Nigh vision

5V2A USB-C

RTSP/ONVIF, Frigate

Also on Amazon.nl, Amazon.co.uk, Domadoo.fr, Itead.cc.

Leave a Comment