Camera.play_stream not working for foscam

Trying to stream front yard camera to Google Smart Display on motion detection.

I have a Ring door bell at the front door and a Foscam camera up at roof level facing the same direction. Prefer to stream the foscam to Google display to preserve Ring battery but want to use Ring motion event to trigger stream from foscam to Google display.

When I try to call camera.play_stream to stream video from camera.foscam_camera_2 to media_play.kitchen.display I get a black screen on the display with the play and pause buttons.

When I do the same thing from a Condor camera in the back yard with rtsp on port 544 it works.

The foscam is configured using the foscam platform:

- platform: foscam
    ip: 192.168.0.11
    username: !secret foscam_account
    password: !secret foscam_password

The Condor camera is configured as an ffmpeg:

  - platform: ffmpeg
    name: Backyard
    input: rtsp://[account]:[password]@192.168.0.12:554/ch01/1

In a VLC Media Player test the foscam camera does work with rtsp://[account]:[password]@[IP]:88/videoMain as does the condor camera with rtsp://[account]:[password]@[IP]:554/ch01/1

However the rtsp settings (port and path) are set in configuration.yaml for the condor but foscam has its own platform support in HA.

So how do I tell camera.play_stream to use the non-standard rtsp setting for the foscam assuming that’s what’s causing the issue?

Did you find a solution? I think that I am on the same boat.
I am trying a very nice AppDaemon based dashboard made by @ReneTode to control my Foscam FI9826P.
In order to show the camera’s stream it needs /api/camera_proxy_stream/camera.fi9826p but no matter what I try it shows a black screen in the box.
I am talking about camera_proxy_stream but I do think the issue has the same origin.

Sidenote: I am noob in HassIO.

you need to have the api password enabled in home assistant. its deprecated, but we still have no other way then the api password.

Hi @ReneTode, thanks for your quick answer.
I do have API password enabled and it is working fine.

Camera_proxy_stream works fine if I configure the camera as ffmpeg instead of foscam.
http://hassio.local:8123/api/camera_proxy_stream/camera.foscam_ffmpeg?api_password=eyJ0eXAiOiJKV1QiLCJhbGciO...blahblah

But if I try
http://hassio.local:8123/api/camera_proxy_stream/camera.fi9826p?api_password=eyJ0eXAiOiJKV1QiLCJhbGciO...blahblah

It shows a black box. No image at all.

Is any way to avoid using a camera_proxy_stream and show the feed from the camera directly in the dashboard? Camera_proxy_stream does post-processing that seems to consume huge amounts of CPU resources and I don’t need it.

@rcruikshank
Sorry if I am hijacking your thread. It is not my intention.

if you can view your cam in a browser without any need for some addons, then you can also use that url in the dashboard.

with my cam types that isnt possible :frowning: so i need to go through HA to get it on dashboard.)

i must say that in the last few HA versions i used the foscam component was gettin worse. (but i didnt try above 0.88 yet)

i have no clue why your cam works with ffmpeg and not with foscam. does it work with the foscam component in the HA frontend?

by the way, your api key looks like a generated token. did you chose that password yourself?

dont worry about hijacking a thread that is 2 months old, when its about a problem.
his problem is probably solved, and if not then its now at least visible again :wink:

but if you feel better by it i can also help you on our appdaemon discord server. (my response there is in most cases faster)

@Tanato
No problem. Haven’t looked at this again.

If you’ve confirmed RTSP working on the Foscam you can just configure it to use the ffmpeg platform in HA.
Unless there are other features provided by the foscam platform that you need (I’m not familiar with that platform).

Edit (P.S.): I haven’t tried it but you might be able to use both platforms simultaneously.

Yes @jparthum. The camera supports RTSP. foscam platform and ffmpeg seems to provide the same results. I didn’t check the resources consumption of each scenario.
And yes, you can use both platforms at the same time. And both work as expected in HassIO.

camera:
  - platform: foscam
    ip: 10.0.0.20
    port: 88 #http: 88 https: 443 ONVIF: 888
    rtsp_port: 88
    name: fi9826p
    username: !secret camera_username
    password: !secret camera_password
  - platform: ffmpeg
    name: foscam_ffmpeg
    input: rtsp://<user>:<pass>@10.0.0.20:88/videoSub
  - platform: proxy
    entity_id: camera.fi9826p
  - platform: proxy
    entity_id: camera.foscam_ffmpeg

foscam platform doesn’t provide any control over PTZ (pan, tilt, zoom) or any other fancy functions and relays on CGI Commands (command_line platform) to get control over them. That makes me think that there aren’t much advantages on choosing foscam platform over ffmpeg.
I started with HassIO last week so please consider this as a noob’s opinion.

Related to AppDaemon as far as I know a proxy is mandatory in order to show an RTSP source feed in a web page. The proxy could be VLAN player, ffmpeg or any other and their main goal is to transcode the RTSP stream to a more friendly format that doesn’t requiere a plugin to be played.

And that is the reason why I suspect that something is not working right with foscam platform when passing the feed to /api/camera_proxy_stream while it does work fine with ffmpeg. May it be a foscam's platform bug? May be me missing something?

I will stick with ffmpeg for the moment.

I tried a little bit more doing:

http://hassio:8123/api/camera_proxy_stream/camera.fi9826p?api_password=<blahblahblah>

And got this in home-assistant.log. I don’t know what it means. Is it a closed connection?

2019-07-29 23:40:17 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 447, in start
    await resp.prepare(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 353, in prepare
    return await self._start(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 667, in _start
    return await super()._start(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 410, in _start
    await writer.write_headers(status_line, headers)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 112, in write_headers
    self._write(buf)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport

I was actually replying to rcruikshank, however your response confirmed what I was suspecting, so it may be more helpful to him than mine alone.

To your HADashboard issue: Are you sure you’re using the right API Password? As ReneTode pointed out,

your api key looks like a generated token

Also, can you view your cam directly from a browser (without using any add-ons)?
eg: By navigating to http://10.0.0.20:88 (or possibly https://10.0.0.20)?

only a rtsp link is available, which you cant view in a browser without an addon.
if we got to the IP directly we need to install an addon.

i dont know if they changed something about that in the latest versions (i know they have worked on cams) but in the HA version i use (0.88) and before i didnt need to do anything but to activate the api password.