dermotduffy / frigate-hass-card

A Lovelace card for Frigate in Home Assistant
MIT License
562 stars 59 forks source link

Casting the card to a TV no longer works after 6.0.0 #1578

Closed felipecrs closed 1 month ago

felipecrs commented 1 month ago

Checklist:

Release with the issue:

6.0.0-beta.3

Last working release (if known):

5.2.0

Browser and Operating System:

Tested on Android TV 9 and Google TV with Android 12, same behavior.

Description of problem:

Casting the card (using cast.show_lovelace_view action) no longer works after 6.0.0, following this conversation.

I was able to confirm it's working with 5.2.0 by downgrading it.

Frigate card diagnostic information

N/A

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

N/A

Additional information:

Not working on 6.0.0:

https://github.com/user-attachments/assets/1dd3b82f-c90b-46fb-be53-3bc55e0b0186

Working on 5.2.0:

https://github.com/user-attachments/assets/b063a86f-65d9-40e2-9c9f-bed15e85d84f

felipecrs commented 1 month ago

@dermotduffy, replying to https://github.com/dermotduffy/frigate-hass-card/pull/1575#issuecomment-2368466011:

Had a quick go, I can get the cast device to sit at "Connected" with the Nabu Casa logo but cannot get any dashboard contents (whether it involves the card or not) to actually show up on the device. Either I'm doing something wrong, or something is up with HA casting...

I was able to get past that issue by clearing the Google Cast App Data in my Android TV settings.

And then, I was able to pinpoint that this issue was introduced by 6.0.0.

PS: it's amazing to see how well it works (casting with very low latency) on 5.2.0.

felipecrs commented 1 month ago

Sorry for not providing more details (I have no idea on how to collect browser logs in such case, although it should be possible).

I am hoping that you will be able to reproduce this issue by yourself.

dermotduffy commented 1 month ago

Mind including the config you are using for both standard and dashboard casting?

felipecrs commented 1 month ago

I am not even trying the cast button of the card; I am trying to call the action through HA dev tools:

action: cast.show_lovelace_view
data:
  entity_id: media_player.tv_da_cozinha
  dashboard_path: dashboard-casting
  view_path: video-porteiro

Such dashboard YAML is:

views:
  - title: Vídeo porteiro
    type: panel
    cards:
      - type: custom:frigate-card
        cameras:
          - camera_entity: camera.video_porteiro
            live_provider: go2rtc
            image:
              refresh_seconds: 1
        profiles:
          - low-performance
        menu:
          style: none
        live:
          controls:
            builtin: false
          show_image_during_load: true
          auto_unmute:
            - selected
            - visible
        dimensions:
          aspect_ratio_mode: static
          aspect_ratio: '16:9'
    path: video-porteiro
felipecrs commented 1 month ago

I just rebuilt my card against latest main to include https://github.com/dermotduffy/frigate-hass-card/pull/1576, but the same problem remains.

With the latest main branch, I simplified my config to:

type: custom:frigate-card
cameras:
  - camera_entity: camera.video_porteiro
    live_provider: go2rtc
profiles:
  - low-performance
  - casting
dermotduffy commented 1 month ago

@felipecrs And just to confirm, with v6, you have the issue with both the standard and dashboard casting methods?

felipecrs commented 1 month ago

No, standard casting method works just fine with v6 (with the expected 10 seconds delay).

dermotduffy commented 1 month ago

Home Assistant + Casting is just so fragile. But I did manage to get this working, once I figured out how to cast any dashboard. It just worked with the v6 code base, so seems to work for me but not for you for some reason:

Service I am calling (can also just use the menu cast button):

action: cast.show_lovelace_view
data:
  entity_id: media_player.nesthub50be
  dashboard_path: lovelace
  view_path: clock

Card config:

type: custom:frigate-card
cameras:
  - camera_entity: camera.office
    live_provider: go2rtc
    cast:
      method: dashboard
      dashboard:
        dashboard_path: lovelace
        view_path: clock
profiles:
  - casting

"clock" is a named path on the main lovelace dashboard of my HA instance.

PS: The low latency is really cool! PPS: I don't think the menu style should be none in the casting profile, since that hides the button most people would use for casting! I think calling the service manually is more an "advanced users" kind of thing...

felipecrs commented 1 month ago

Interesting, you are using it in a completely different way I am.

In my case, I have my regular dashboard with the card where I have all buttons normally.

Then, I have a separate, hidden dashboard, which I only use for casting.

I think it makes more sense doing this way, so that you can have a card fully configured for the best looking and performance on a TV.

Then, in my normal dashboard, I'd just setup the Frigate card to cast using my casting dashboard.

BTW Since you can't reproduce it, I will try a little more. See if I can figure something out.

Thank you!

dermotduffy commented 1 month ago

I think it makes more sense doing this way, so that you can have a card fully configured for the best looking and performance on a TV.

This does make sense, but I think for a user just trying to cast a dashboard "casually", I don't think they'd start with this and perhaps be a little confused the menu is suddenly gone. In addition, you can cast to a touch device (e.g. Nest hub) where you actually can use the menu, so I think it might make more sense to not be opinionated as to the menu in the profile.

felipecrs commented 1 month ago

Sure. If you think so. The user would have the ability of hiding it anyway.

cvroque commented 1 month ago

Just wanted to say I have the same issue, this is my card config on 6.0 Beta 4: type: custom:frigate-card

title: Câmera Externa Deck
path: externa_deck
type: panel
cards:
  - type: custom:frigate-card
    cameras:
      - camera_entity: camera.externa_deck
        live_provider: go2rtc
    profiles:
      - casting

I'm trying to cast the dashboard to my Google TV devices straight from HA. The previous version works fine

dermotduffy commented 1 month ago

I'm trying to cast the dashboard to my Google TV devices straight from HA.

@cvroque Not sure this is the same issue, since you're not using the dashboard casting method in your config. How are you actually doing the casting in this case?

felipecrs commented 1 month ago

@dermotduffy, he's probably doing the same as me. He's triggering the cast using the media browser or through the cast.show_lovelace_view action:

action: cast.show_lovelace_view
data:
  entity_id: media_player.tv_da_cozinha
  dashboard_path: dashboard-casting
  view_path: video-porteiro
felipecrs commented 1 month ago

BTW Since you can't reproduce it, I will try a little more. See if I can figure something out.

I did more testing and was unable to find anything useful. I'm surprised you can't reproduce it. Are you trying with a similar configuration as we?

dermotduffy commented 1 month ago

Config and service shown in this comment. It casts fine on a NestHub, let me try some different devices when I get a chance in case it's a device specific success.

felipecrs commented 1 month ago

This is how it looks like when I try casting my main dashboard, which has three Frigate cards in it:

image

felipecrs commented 1 month ago

If only I could access the browser logs for it... but according to this page, I need to pay a 5 USD fee for it (unbelievable!).

I don't have any Nest Hub myself, but my brother does. When I get the chance, I will try on his house as well.

In my case I only have Android TV devices with Chromecast built in.

dermotduffy commented 1 month ago

In my case I only have Android TV devices with Chromecast built in.

... I also have one of these. Will try.

cvroque commented 1 month ago

I'm trying to cast the dashboard to my Google TV devices straight from HA.

@cvroque Not sure this is the same issue, since you're not using the dashboard casting method in your config. How are you actually doing the casting in this case?

Hey! I was on mobile and left out a few details, sorry.

I had been casting an entire dashboard with a single frigate card for a while through HA (in order to get the lowest latency), then I saw the newly added beta option and decided to update and configure it.

After adding the new cast method none of my cameras worked and then I noticed that even casting directly stopped working.

In order to provide helpful information, I created a very simple card:

type: custom:frigate-card
cameras:
  - camera_entity: camera.sala

In order to test casting from the card, after updating to Beta 4 I added:

type: custom:frigate-card
cameras:
  - camera_entity: camera.sala
    cast:
      method: dashboard
      dashboard:
        dashboard_path: dash-cast
        view_path: sala

Here are the results:

Device Version Casting Method Result Details
Nest Hub v1 V5.2 Standard Delay
Nest Hub v1 V5.2 HA (cast.show_lovelace_view) No Delay
Nest Hub v1 V6.0 Standard Delay
Nest Hub v1 V6.0 HA (cast.show_lovelace_view) No Delay
Nest Hub v1 V6.0 Dashboard No Delay
Google TV 4k V5.2 Standard Delay
Google TV 4k V5.2 HA (cast.show_lovelace_view) No Delay
Google TV 4k V6.0 Standard Delay
Google TV 4k V6.0 HA (cast.show_lovelace_view) Endless Spinning
Google TV 4k V6.0 Dashboard Endless Spinning
dermotduffy commented 1 month ago

Thanks so much @cvroque, that's really helpful. So it does look like there's some sort of device specific behavior going on. I just tried on my Android TV, and like you -- I get the loading "spinner" that just just spins forever.

Guess I'll give this a shot: https://developers.google.com/cast/docs/android_tv_receiver/debugging

dermotduffy commented 1 month ago

(You would not believe the hoops I had to jump through to get this. So much time, I won't be able to do anything about it today, but have a starting point at least...)

image

felipecrs commented 1 month ago

That's crazy! But I am very grateful for your effort.

dermotduffy commented 1 month ago

I think it's an obscure bug in whatever browser library/engine is running on the cast devices, that causes whenDefined to return undefined instead of a constructor. Possible this bug, or similar: https://issues.chromium.org/issues/40846966

dermotduffy commented 1 month ago

Search keywords: debug cast androidtv CAST_DEV_APP_ID CAST_DEV_HASS_URL

In case it helps anyone in future, here is what I did to get access to the debug console logs for casting to Android TV devices. Perhaps there is an easier way, but after hours of trying to find it, this was what worked:

In my case, I also ran into an apparent bug in the HA cast launcher itself, and had to use a version before this PR or my clicks on the cast dashboard didn't seem to work. I'll confirm if that's the case and file a bug about it if so.

felipecrs commented 1 month ago

OMG. Paying the fee was the easiest part then.

Well, on the bright side now you are a Cast expert. 😅

Thank you very much for the detailed debugging instructions.

felipecrs commented 1 month ago

I can confirm https://github.com/dermotduffy/frigate-hass-card/pull/1601 fixes the issue for me.

dermotduffy commented 1 month ago

I can confirm #1601 fixes the issue for me.

Woohoo. Thanks for checking! Calling this one done, then.

oerix commented 2 weeks ago

Does casting not support Chromecast gen 2? All I'm getting is a black screen, when casting through the frigate card v6.0.0-beta-8

Failed to perform the action media_player/play_media. CastMediaPlayerEntity._quick_play Failed: Execution of quick play http://192.168.1.122:8123/api/hls/a546d68a228ca190b87d53fff5a871a5c55ea385af0c0f8af4cd4c115fd3ef20/master_playlist.m3u8?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJkY2ViOTVhOTY0ODM0ODlkODczYWQyNDA0NzY1ZDEzZiIsInBhdGgiOiIvYXBpL2hscy9hNTQ2ZDY4YTIyOGNhMTkwYjg3ZDUzZmZmNWE4NzFhNWM1NWVhMzg1YWYwYzBmOGFmNGNkNGMxMTVmZDNlZjIwL21hc3Rlcl9wbGF5bGlzdC5tM3U4IiwicGFyYW1zIjpbXSwiaWF0IjoxNzMwNDAxODMyLCJleHAiOjE3MzA0ODgyMzJ9.GQxCyGA1YtgpgCQJb6cZk7hk7kOxrul7MejqscQtwsU timed out after 30.0 s.
felipecrs commented 2 weeks ago

Does casting any dashboard using http://cast.home-assistant.io work?

oerix commented 2 weeks ago

Does casting any dashboard using http://cast.home-assistant.io work?

Yeh, seems to work. I see the nabu casa and ha logo with 'connected' showing, and demo dashboard preview works. From the error message above, I'd imagine the issue is that it's serving through http instead of https?

I'm using dashboard through https and not locally, so not sure what the issue is tbh.

felipecrs commented 2 weeks ago

image

Is this setting right in your HA? /config/network

cvroque commented 2 weeks ago

This just stopped working for me yesterday, which is weird since I didn't update anything relevant (HA, Frigate, Go2rtc). I can cast normally any dashboard but this card never loads the stream and just shows this image:

image

The other card elements are loading fine, even picture-entity. I also tried a very barebone card configuration and the issue persisted:

type: custom:frigate-card
cameras:
  - camera_entity: camera.sala
felipecrs commented 2 weeks ago

I just confirmed it's still working for me. But I'm testing against a Chromecast with Google TV 4k.

Barebone configuration isn't ideal for this btw, especially on such a low powered device. You should at least use the low-performance profile.

https://card.camera/#/usage/casting?id=dashboard-casting

felipecrs commented 2 weeks ago

Make sure you are using the latest beta version of the card by the way.

cvroque commented 2 weeks ago

I just confirmed it's still working for me. But I'm testing against a Chromecast with Google TV 4k.

Barebone configuration isn't ideal for this btw, especially on such a low powered device. You should use the casting profile.

https://card.camera/#/usage/casting?id=dashboard-casting

I'm able to replicate this on my Google TV 4k and Nest Hub. My default card uses the casting profile, the barebones was just another test.

I've found some error logs and will open a new issue later:

2024-10-31 17:42:39.277 ERROR (Thread-12) [pychromecast.socket_client] [Google TV Suíte(192.168.68.244):8009] Unhandled exception in worker thread, attempting reconnect
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/pychromecast/socket_client.py", line 543, in run
if self._run_once(timeout=POLL_TIME_BLOCKING) == 1:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pychromecast/socket_client.py", line 640, in _run_once
self._request_callbacks.pop(data[REQUEST_ID])(True, data)
File "/usr/local/lib/python3.12/site-packages/pychromecast/controllers/receiver.py", line 217, in handle_launch_response
callback_function(True, response)
File "/usr/local/lib/python3.12/site-packages/pychromecast/response_handler.py", line 71, in _callback
on_success(callback_function=callback_function)
File "/usr/local/lib/python3.12/site-packages/pychromecast/controllers/__init__.py", line 186, in send_message_nocheck
self._message_func(
File "/usr/local/lib/python3.12/site-packages/pychromecast/socket_client.py", line 950, in send_app_message
raise UnsupportedNamespace(
pychromecast.error.UnsupportedNamespace: Namespace urn:x-cast:com.nabucasa.hast is not supported by current app. Supported are urn:x-cast:com.google.cast.sse, urn:x-cast:com.google.cast.cac
oerix commented 2 weeks ago

image

Is this setting right in your HA? /config/network

Yes, everything is set correctly. It's only Casting using the Frigate card I'm having issue with.