Skip to content

felipecrs/hass-expose-camera-stream-source

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Please star this integration in GitHub if it helps you!

Expose Camera Stream Source

A Home Assistant integration to expose an API for retrieving the camera stream source URL.

It allows to import Tuya, Nest and possibly other cameras from Home Assistant to go2rtc or Frigate.

Note, however, that this integration will only work if you are already able to view your camera stream in Home Assistant through HLS.

For cameras that exclusively work through WebRTC this integration will not help. It is the case for Nest cameras migrated to Google Home and certain Tuya cameras, for example.

Alternatives

Important

Prefer adding your camera to go2rtc natively using the methods below. They work better.

  • Nest cameras migrated to Google Home are supported natively in go2rtc through the Nest source.
  • Tuya cameras are supported natively in go2rtc through the Tuya source since v1.9.13.
  • Cameras that only support still images can be added to go2rtc through this method.

Installation

Easiest install is via HACS:

  1. Click the button below to install this integration via HACS:

    Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

  2. Restart Home Assistant.

  3. Click the button below to setup the integration:

    Open your Home Assistant instance and start setting up a new integration.

Now the integration should be active.

Importing cameras from Home Assistant to go2rtc or Frigate

This integration can be used to import cameras from Home Assistant to go2rtc or Frigate.

Important

Before importing to go2rtc, let's make sure a stream source is available for your camera. Simply run this command in the Terminal or Studio Code Server add-on:

curl -fsSL http://supervisor/core/api/camera_stream_source/camera.my_camera -H "Authorization: Bearer ${SUPERVISOR_TOKEN}"

Replacing camera.my_camera with your camera entity ID.

If you have no access to add-ons, you will need to replace ${SUPERVISOR_TOKEN} with your Home Assistant long-lived access token and http://supervisor/core with the IP address or URL of your Home Assistant. Read below for more details. If you are on Windows, you can run that command in PowerShell by changing curl to curl.exe.

After running it, it should output an RTSP or HTTP URL.

If it did not, sorry but stream source is not available for your camera.

If it did, copy this URL and try to play it in VLC.

Be quick though, some URLs expire after a few seconds if no connection is made. You can generate a new one by running the command again.

If it does not play in VLC, it will not play in go2rtc or Frigate either. Sorry.

Here is an example of how to do it in your go2rtc configuration file:

# go2rtc.yaml

streams:
  my_camera:
    - 'echo:curl -fsSL http://supervisor/core/api/camera_stream_source/camera.my_camera -H "Authorization: Bearer ${SUPERVISOR_TOKEN}"'

Or, if you are using Frigate, here is how you can do the same in your Frigate configuration file:

# config.yml

go2rtc:
  streams:
    my_camera:
      - 'echo:curl -fsSL http://supervisor/core/api/camera_stream_source/camera.my_camera -H "Authorization: Bearer ${SUPERVISOR_TOKEN}"'

cameras:
  my_camera:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/my_camera?video
          input_args: preset-rtsp-restream-low-latency
          roles:
            - detect

Replacing camera.my_camera with your Home Assistant camera entity ID.

Note that you do not need to replace ${SUPERVISOR_TOKEN} or make any further changes if you are running go2rtc through the WebRTC integration, go2rtc add-on, or Frigate add-on.

Otherwise, you need to replace ${SUPERVISOR_TOKEN} with your Home Assistant long-lived access token. To generate one:

  1. Go to your Home Assistant profile page: Open your Home Assistant instance and show your Home Assistant user's profile.
  2. Scroll down to Long-Lived Access Token, and click in Create Token.
  3. Give it a name, like go2rtc and press Ok.

Additionally, you need to replace http://supervisor/core with the IP address or URL of your Home Assistant instance. Example:

streams:
  my_camera:
    - 'echo:curl -fsSL http://192.168.1.10:8123/api/camera_stream_source/camera.my_camera -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI4ZDljNzU4NjM2OGQ0NzI0YmJhZjVlODBmZDdjODMwMiIsImlhdCI6MTc0ODA0OTc4OSwiZXhwIjoyMDYzNDA5Nzg5fQ.RmV0VN43byRA-azB8N7jUn2j7W9LRppJlzQ1aOQcnFc"'

About

Allows to import Home Assistant cameras into go2rtc and Frigate

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors