natekspencer / hacs-vivint

Home Assistant integration for a Vivint home security system.
MIT License
66 stars 5 forks source link

Derive RTSP Stream of existing Vivint cameras for other add-ons like Frigate #11

Closed thelightningist closed 2 years ago

thelightningist commented 3 years ago

I was able to get this integration working wonderfully but wanted to try and take it a step further. I was curious about feeding the added camera entity's RTSP stream into frigate via their configuration file. However, I am unable to determine what the RTSP stream URL is of the existing entities (for example, camera.doorbell entity) in order to add them into Frigate.

These clearly are added as RTSP streams already and I can view them in Lovelace. Is there some sort of simple method to find this information so that I can add these cameras into frigate?

apercrcl01 commented 3 years ago

I am interested in this as well.

DarellAdams commented 3 years ago

I was trying to write a python script to extract the internal RTSP url from the panel but the API broke after Vivint had their maintenance, I'm hoping they fix it soon so I can share with you guys

EDIT: As I wrote this comment, the repository was update and was able to finish this script https://gist.github.com/DarellAdams/1721590ab83443f43eea0c6391c39380

usage as following: python camRTSP.py [username] [password]

output

DEBUG:root:                     Device: <Camera, Cam1>
Internal rtsp URL non-hd: [URL]
Internal rtsp URL hd: [URL]
External rtsp URL non-hd: rtsp[URL]
External rtsp URL hd: rtsp[URL]
DEBUG:root:                     Device: <Camera, Cam2>
Internal rtsp URL non-hd: [URL]
Internal rtsp URL hd: [URL]
External rtsp URL non-hd: rtsp[URL]
External rtsp URL hd: [URL]
natekspencer commented 3 years ago

It wouldn't be hard to expose this at all. If I recall, I even exposed it at one point in my initial iteration of the component as an attribute on the camera, but then decided to remove it from the published file because it could be a security issue (especially for external sources). But this section https://github.com/natekspencer/hacs-vivint/blob/a189ea2fc289db464f6ebc112e5d211091ad5556/custom_components/vivint/camera.py#L78 is where you would get the stream source, which is the RTSP url.

thelightningist commented 3 years ago

Hi @DarellAdams

Thanks so much for sharing your script! Just so I understand this correctly, where exactly do you place the cameraRTSP script at? The vivint folder under custom_componets?

When I try running it from the terminal in Visual Studio Code after adding the file, I get the same error from running the script if it's in the config folder or custom_componets/vivint/ folder:

Traceback (most recent call last):
  File "camRTSP.py", line 5, in <module>
    from vivintpy.account import Account
ModuleNotFoundError: No module named 'vivintpy'
DarellAdams commented 2 years ago

@thelightningist Sorry for the late reply. You actually need to run this on a laptop/client computer.

  1. On your Mac/PC, run a terminal, cmd, or powershell
  2. Make sure you have python3 installed (Just google it to install)
  3. Make sure module vivintpy is installed (install vivintpy module: pip install vivintpy)
  4. On terminal, cd /path/of/the/scirpt/ (e.i cd C:\Scripts)
  5. C:\Scripts> python3 camRTSP.py [username] [password]
natekspencer commented 2 years ago

I just released version 2021.9.5 that includes the ability to enable logging of the rtsp urls via the configure option on the integration. Please note that you also have to have logging enabled in your configuration.yaml file with custom_components.vivint set to a minimum of info. Here's an example:

logger:
  default: error
  logs:
    custom_components.vivint: info
thelightningist commented 2 years ago

Awesome! Thanks so much!

elreydetoda commented 3 weeks ago

a "low tech" alternative is if you just navigate to home assistant dashboard, which should load all the vivint cameras (at least my default & minimal install does), then it'll run an ffmpeg command in the background. So, if you just do this it'll show you the full rtsp stream:

sudo ps -aux | grep '[f]fmpeg'

at least that's works for me on 2024.4.0

Every time I enabled the "Log camera RTSP URLS" option in the config I got this:

rtsp://****:****@<IP>:554/stream1,audio=opus

Where the * were actual * & not me replacing for sensitive information.

To be clear, I'm not complaining & honestly I don't need a native way to handle it (so this isn't me trying to get any extra work done for the project), I just wanted to post it as an alternative way to find the URLs.

Thank you so much to all the contributors for all the hard work on this project! It's amazing :grin: :tada: