[Integration] Android TV live cam video streams in a Picture in Picture triggered by motion detection. AKA video-doorbell

That’s what i am trying to figure out. I am unable to find the frigate link to a specific camera.

Mostly that’s http://haipaddress:5000/api/cameraname where you repalce haipaddress with the actual ip address of your ha instance and cameraname with the name you gave your camera, but this is very specific to an environment. So don’t think anyone can help you with this. I also made the assumption you run your frigate as addon on hassio and selected port 5000 (and have it enabled as such in the configuration part of the addon).

1 Like

Port 5000 was disable by default. I enabled it and the link is working now. Thanks for your help.

2 Likes

Tip:
Add these lines in the automation. I see that alot are having the same issue that PipUp are not running after a while.

  • service: androidtv.adb_command
    data:
    command: >-
    ps -ef | grep -v grep | grep pipup || adb shell am start
    nl.rogro82.pipup/.MainActivity
    target:
    entity_id:
    - media_player.nividia_shield
    - service: androidtv.adb_command
    data:
    command: input keyevent KEYCODE_WAKEUP
    target:
    entity_id:
    - media_player.nividia_shield

I’m stugging to get it to work - the temporary URL (captured from trace) works fine externally or internally in any browser but not on the AndroidTV.
I’m using the built in go2rtc with the WebRTC Plugin. HA is hosted in docker in Synology.

service: rest_command.pipup_url_on_tv
data:
  title: Door
  message: Someone is at the front door
  width: 640
  height: 480
  url: https://<mydns>/webrtc/embed?url={{ link_id }}
  duration: 60

I’m using the apk from Sean’s guide.

Any idea?

What happens if you paste this url in a regular browser. I imagine it won’t work. How do you fill the variable?

It works fine both internal and external to my network.

https://xxxxxxxxx/webrtc/embed?url=8653384037128690460903504234864334989821
Loads the video feed instantly (as MSE).

Executed: 18 September 2023 at 18:48:15
Result:

params:
  domain: rest_command
  service: pipup_url_on_tv
  service_data:
    title: Door
    message: Someone is at the front door
    width: 640
    height: 480
    url: >-
      https://xxxxxxxxx/webrtc/embed?url=8653384037128690460903504234864334989821
    duration: 30
  target: {}
running_script: false

I’ve installed the go2rtc docker from alexxit/go2rtc and the WebRTC Camera plugin to HA.

go2rtc automatically picked up my cameras when the plugin connected:

I’ve tried using the front_door entity as well as the rtsp feeds (via “url:” in the webrtc.create_link section)

Weird. I’m just using a static url. Which works for me. Can’t test for you unfortunately since I’m on holiday for another two weeks. Hopefully you get it sorted

Yea, makes no sense - I can’t see anything wrong. I’ll try a static external link and see if that works.

Are HA and android tv on the same subnet? Have you tried a youtube link instead of your internal one? Just so rule things out.

Got everything working (almost). One question:

When PipUp renders on the Nvidia shield and the WebRTC stream starts it pauses any other content currently playing. Anyway to solve this?

(Using UniFi G4 Instant camera)

It’s the same for me. Have you got a solution? Thanks

If you don’t pass through Audio it shouldn’t pause the video

So something like this:
http://ip:port/webrtc.html?src=unify_camera&media=video

Instead of this:
http://ip:port/webrtc.html?src=unify_camera&media=video-audio

1 Like

Do you mean in my Go2rtc config or in the scripts.yaml? Thanks!

You sir… are a legend… :slight_smile:

Thank you for your comment. This helped me to finally understand my problem to get a working link from the rtc service.
Before i got constantly ERR_CONNECTION_REFUSED and nothing worked.

In the script.yaml my last line now looks like

 url: http://192.168.1.5:8123/webrtc/embed?url={{ link_id }}

which really needed the port of my HASS instance here to work.
Maybe it also helps someone else :slight_smile: Used the APK from DesertBlade.
Thank you all for sharing here! Very much appreciated.

I got this working recently as well! I took a LOT of inspiration from Sean’s guide, but made a more “step-by-step guide”. I use Windows instead of Linux, and had to use an alternative APK that allowed for not https:// links.

This means, no port forwarding was necessary.

Hopefully it helps a few of you do the same, because this is one of my favorite setups to date: Display Picture-in-Picture Live Camera Feeds on Nvidea Shield using Home Assistant - Smart Home Sysadmin

1 Like

I’m having trouble setting up a second shield.
What would be the correct way to have two up and running?

First one worked fine, so I set up the second and got the second running. But this also caused a conflict somewhere with the first
Even if I remove the second shield from the rest_command.yaml I can’t push to the first on port 7979 anymore.

When I try through CMD I get
curl: (7) Failed to connect to xxx.xxx.x.xx port 7979 after 2038 ms: Couldn't connect to server

pipup_url_on_tv:
  # Use with Webrtc camera as described here:
  # https://github.com/AlexxIT/WebRTC/wiki/Cast-or-share-camera-stream#html-page
  url: http://xxxxxx:7979/notify
  content_type: 'application/json'
  verify_ssl: false
  method: 'post'
  timeout: 20
  payload: >
    {
      "duration": {{ duration | default(20) }},
      "position": {{ position | default(0) }},
      "title": "{{ title | default('') }}",
      "titleColor": "{{ titleColor | default('#50BFF2') }}",
      "titleSize": {{ titleSize | default(10) }},
      "message": "{{ message }}",
      "messageColor": "{{ messageColor | default('#fbf5f5') }}",
      "messageSize": {{ messageSize | default(14) }},
      "backgroundColor": "{{ backgroundColor | default('#0f0e0e') }}",
      "media": { 
        "web": {
          "uri": "{{ url }}", 
          "width": {{ width | default(640) }},
          "height": {{ height | default(480) }}
        }
      }
    }
pipup_url_on_tv2:
  # Use with Webrtc camera as described here:
  # https://github.com/AlexxIT/WebRTC/wiki/Cast-or-share-camera-stream#html-page
  url: http://xxxxxxxxx:7979/notify
  content_type: 'application/json'
  verify_ssl: false
  method: 'post'
  timeout: 20
  payload: >
    {
      "duration": {{ duration | default(20) }},
      "position": {{ position | default(0) }},
      "title": "{{ title | default('') }}",
      "titleColor": "{{ titleColor | default('#50BFF2') }}",
      "titleSize": {{ titleSize | default(10) }},
      "message": "{{ message }}",
      "messageColor": "{{ messageColor | default('#fbf5f5') }}",
      "messageSize": {{ messageSize | default(14) }},
      "backgroundColor": "{{ backgroundColor | default('#0f0e0e') }}",
      "media": { 
        "web": {
          "uri": "{{ url }}", 
          "width": {{ width | default(640) }},
          "height": {{ height | default(480) }}
        }
      }
    }

Oh my! This works great. I’m using an AT&T/DirecTV Gemini (Osprey) streaming box which, BTW, does not work with Notifications for Android TV. Thank you. :grin:

Excellent work mate. I was really reluctant to expose the stream outside and setup SSL/TLS. Nevertheless, credits to everyone’s efforts here.