home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
4.04k stars 2.76k forks source link

Stream component / rtsp feed in lovelace #2987

Closed memphisdj closed 5 years ago

memphisdj commented 5 years ago

Home Assistant release with the issue:

0.90.0 Last working Home Assistant release (if known): N/A UI (States or Lovelace UI?):

Lovelace Browser and Operating System:

Chrome Version 73.0.3683.86 (Official Build) (64-bit) OS: hassio in docker on ubuntu 18.04 Description of problem:

Im trying to use the new stream: component to display my rtsp feed whitin the frontend, but i am getting Uncaught ReferenceError:

2019-03-21 19:41:12 ERROR (MainThread) [frontend.js.es5.201903200] blob:https://xxx.xxx.com/ffa524c1-bdf1-42b7-d1ba7196ef40:1:2380 Uncaught ReferenceError: s is not defined

The camera is stuck on this screen: image

Javascript errors shown in the web inspector (if applicable): image

dshokouhi commented 5 years ago

I am also seeing these errors but only in one of my dev instances that I setup the other day. I do not see this issue on my raspberry pi running the dev branch. I am running windows subsystem for linux on windows 10 following the instructions on the dev page:

https://developers.home-assistant.io/docs/en/development_environment.html#developing-on-windows

These are the console errors I see:

2019-03-21 11:07:07 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/cbcef3b3f88b95d17a471b97dc23430180c7b6e10363d1d2bca625403e620c0f/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:07 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/cbcef3b3f88b95d17a471b97dc23430180c7b6e10363d1d2bca625403e620c0f/segment/1.ts to 127.0.0.1 (auth: False)
2019-03-21 11:07:07 ERROR (MainThread) [frontend.js.es5.201903200] blob:http://localhost:8123/9510b70f-cb08-47f1-aae5-416be93055cf:1:2380 Uncaught ReferenceError: s is not defined
2019-03-21 11:07:07 ERROR (MainThread) [frontend.js.es5.201903200] blob:http://localhost:8123/9510b70f-cb08-47f1-aae5-416be93055cf:1:6333 Uncaught ReferenceError: s is not defined
2019-03-21 11:07:11 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/cbcef3b3f88b95d17a471b97dc23430180c7b6e10363d1d2bca625403e620c0f/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:17 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/cbcef3b3f88b95d17a471b97dc23430180c7b6e10363d1d2bca625403e620c0f/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:24 INFO (MainThread) [homeassistant.components.stream] Started stream: rtsp://user:password@192.168.1.x:554/cam/realmonitor?channel=1&subtype=1
2019-03-21 11:07:24 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:48 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:48 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:48 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/segment/2.ts to 127.0.0.1 (auth: False)
2019-03-21 11:07:48 ERROR (MainThread) [frontend.js.es5.201903200] blob:http://localhost:8123/6d75ea6d-b40d-40d0-ad9b-d8129564eddd:1:2380 Uncaught ReferenceError: s is not defined
2019-03-21 11:07:48 ERROR (MainThread) [frontend.js.es5.201903200] blob:http://localhost:8123/6d75ea6d-b40d-40d0-ad9b-d8129564eddd:1:6333 Uncaught ReferenceError: s is not defined
2019-03-21 11:07:49 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:50 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:50 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:51 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:52 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:52 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)

You can see the stream is attempting to start but seems like maybe some frontend error is preventing it maybe?

Browser used was Chrome 73 on Windows 10 and same issue happens on my Pixel 3 XL Android 9

memphisdj commented 5 years ago

I am also seeing these errors but only in one of my dev instances that I setup the other day. I do not see this issue on my raspberry pi running the dev branch. I am running windows subsystem for linux on windows 10 following the instructions on the dev page:

https://developers.home-assistant.io/docs/en/development_environment.html#developing-on-windows

These are the console errors I see:

2019-03-21 11:07:07 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/cbcef3b3f88b95d17a471b97dc23430180c7b6e10363d1d2bca625403e620c0f/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:07 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/cbcef3b3f88b95d17a471b97dc23430180c7b6e10363d1d2bca625403e620c0f/segment/1.ts to 127.0.0.1 (auth: False)
2019-03-21 11:07:07 ERROR (MainThread) [frontend.js.es5.201903200] blob:http://localhost:8123/9510b70f-cb08-47f1-aae5-416be93055cf:1:2380 Uncaught ReferenceError: s is not defined
2019-03-21 11:07:07 ERROR (MainThread) [frontend.js.es5.201903200] blob:http://localhost:8123/9510b70f-cb08-47f1-aae5-416be93055cf:1:6333 Uncaught ReferenceError: s is not defined
2019-03-21 11:07:11 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/cbcef3b3f88b95d17a471b97dc23430180c7b6e10363d1d2bca625403e620c0f/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:17 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/cbcef3b3f88b95d17a471b97dc23430180c7b6e10363d1d2bca625403e620c0f/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:24 INFO (MainThread) [homeassistant.components.stream] Started stream: rtsp://user:password@192.168.1.x:554/cam/realmonitor?channel=1&subtype=1
2019-03-21 11:07:24 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:48 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:48 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:48 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/segment/2.ts to 127.0.0.1 (auth: False)
2019-03-21 11:07:48 ERROR (MainThread) [frontend.js.es5.201903200] blob:http://localhost:8123/6d75ea6d-b40d-40d0-ad9b-d8129564eddd:1:2380 Uncaught ReferenceError: s is not defined
2019-03-21 11:07:48 ERROR (MainThread) [frontend.js.es5.201903200] blob:http://localhost:8123/6d75ea6d-b40d-40d0-ad9b-d8129564eddd:1:6333 Uncaught ReferenceError: s is not defined
2019-03-21 11:07:49 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:50 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:50 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:51 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:52 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)
2019-03-21 11:07:52 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/0595f44808c42387d4983da01543eed3c204114e4c750a64fdd3ae862a3b761e/playlist.m3u8 to 127.0.0.1 (auth: False)

You can see the stream is attempting to start but seems like maybe some frontend error is preventing it maybe?

I am running hassio in docker on ubuntu 18.04, not windows 10. I just edited my original post.

dshokouhi commented 5 years ago

Adding on to my experience. I updated my prod instance of HA to 0.90.1 which is running in a venv on ubuntu 18.10 and this issue does not exist there. Might be related to certain installs maybe?

@aleksandrov1995 what camera are you using?

memphisdj commented 5 years ago

Adding on to my experience. I updated my prod instance of HA to 0.90.1 which is running in a venv on ubuntu 18.10 and this issue does not exist there. Might be related to certain installs maybe?

@aleksandrov1995 what camera are you using?

Hikvision dvr with 4 analog cameras, but it provides the rtsp stream.

dshokouhi commented 5 years ago

@aleksandrov1995 are you able to use the camera.play_stream service call on a cast device? I am able to stream my camera to my google home hub but I cannot play it in the front end. I suspect that may be the case for you as well.

Here is the log so we can see that it successfully plays on a cast device but not in the browser.

2019-03-23 14:03:25 INFO (MainThread) [homeassistant.components.stream] Started stream: rtsp://user:password@192.168.1.x:554/cam/realmonitor?channel=1&subtype=0
2019-03-23 14:03:25 INFO (SyncWorker_3) [pychromecast.controllers] Receiver:Launching app CC1AD845
2019-03-23 14:03:26 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/playlist.m3u8 to 192.168.1.89 (auth: False)
2019-03-23 14:03:28 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/playlist.m3u8 to 192.168.1.89 (auth: False)
2019-03-23 14:03:28 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/segment/1.ts to 192.168.1.89 (auth: False)
2019-03-23 14:03:30 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/playlist.m3u8 to 192.168.1.89 (auth: False)
2019-03-23 14:03:30 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/segment/2.ts to 192.168.1.89 (auth: False)
2019-03-23 14:03:32 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/playlist.m3u8 to 192.168.1.89 (auth: False)
2019-03-23 14:03:32 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/segment/3.ts to 192.168.1.89 (auth: False)
2019-03-23 14:03:34 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/playlist.m3u8 to 192.168.1.89 (auth: False)
2019-03-23 14:03:34 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/segment/4.ts to 192.168.1.89 (auth: False)
2019-03-23 14:03:36 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/playlist.m3u8 to 192.168.1.89 (auth: False)
2019-03-23 14:03:36 INFO (MainThread) [homeassistant.components.http.view] Serving /api/hls/81eebaac74a9a4efa11bb07e52e5e231ddf4f35f232e721d6b3340c991ffa6ed/segment/5.ts to 192.168.1.89 (auth: False)

The previous log kept sending the playlist however this log we can see after the playlist segments are being served properly. On my system where I do not experience this bug (venv on raspberry and other hardware) the logs are identical to above.

dshokouhi commented 5 years ago

Just adding on to my experience, someone in the forums mentioned to append ?latest to the frontend URL and see if that works. I just tried it and sure enough the frontend loaded right away. I made sure to retest this in incognito mode. If I do not add ?latest the video never loads and gives me the error, not sure if that suggests a caching issue because this entire time I have been testing in incognito mode which clears cache the moment the browser is closed. Hopefully this helps out more.

dshokouhi commented 5 years ago

Based on the docs it looks like its possible that certain installations of HA do not detect the javascript_version: properly:

https://www.home-assistant.io/components/frontend/#javascript_version

Once I add the following to my configuration.yaml the player loads fine (as expected due to previously mentioned URL addition), its important to note that in all my other HA installations this is not an issue. So this may not be an issue about stream but maybe around the javascript detection?

frontend:
  javascript_version: latest
memphisdj commented 5 years ago

Based on the docs it looks like its possible that certain installations of HA do not detect the javascript_version: properly:

https://www.home-assistant.io/components/frontend/#javascript_version

Once I add the following to my configuration.yaml the player loads fine (as expected due to previously mentioned URL addition), its important to note that in all my other HA installations this is not an issue. So this may not be an issue about stream but maybe around the javascript detection?

frontend:
  javascript_version: latest

Man you are a legend, indeed adding the above to the config, solved the issue completely. The only thing that i am noticing is that, the player chaches the video and plays it with 30 seconds behind the live rtsp stream. Thanks for looking further into the issue.

madiskallas commented 4 years ago

Adding this worked and ended my 2 hours of finding a fix :) Thank you

frontend:
  javascript_version: latest