Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native cast support #439

Closed
felipecrs opened this issue Mar 4, 2022 · 5 comments
Closed

Add native cast support #439

felipecrs opened this issue Mar 4, 2022 · 5 comments

Comments

@felipecrs
Copy link
Contributor

felipecrs commented Mar 4, 2022

A cast button to leverage the recently introduced Home Assistant Play Media action to show a camera stream in a Chromecast enabled media player.

When clicked, it would open a dropdown menu allowing to select which media player to cast the current camera stream to.

When selected, the card can then trigger the Play Media action passing in the current camera entity as input, in the selected media player.

It would be disabled for birdseye, by the way.

I haven't tried to build my own custom buttons yet (and I wonder how far it would be possible), but the following are the reasons why I'm opening this suggestion:

  1. I believe it's a quite common and generic use case. It would be nice to support it out-of-the-box, as HA now also does.
  2. I don't think the current tap_action syntax provides the means to call a Play Media action (which is not a service, by the way). But I suppose the card can do it, though.
  3. If provided by the card, it can automatically decide to hide the button in case no suitable media players are found.
  4. If provided by the card, I suppose it can also color the icon based on the media_player state (whether it has started to stream the given camera or not), although this can come as an enhancement later (if possible at all).

What do you think?

@dermotduffy dermotduffy changed the title Cast menu button Add native cast support Mar 5, 2022
@dermotduffy dermotduffy added this to the v4.0.0 milestone Mar 5, 2022
@dermotduffy
Copy link
Owner

Hi @felipecrs , sounds like a good suggestion.

When selected, the card can then trigger the Play Media action passing in the current camera entity as input, in the selected media player.

I think it hinges on this: whether or not / how a custom card can actually do this . It has to be via HA in order to get the HA media devices, which means it depends on HA having externalized that support somehow. The HA frontend is an enormous Javascript blob, and it is tricky -- and in some cases not possible -- for custom cards to get access to parts of it (here's an example of where the card needs to fake load a picture glance card to get access to the editor widgets).

i.e. more research required on whether this is feasible right now.

@dermotduffy
Copy link
Owner

Hmm. Maybe this is less of a big deal than I was thinking:

  • Can get the media players from the entities in the provided HA state.
  • Can call select_source and play_media services.

UX:

  • A cast icon appears in the menu on camera streams (and ideally clips)
  • Clicking the icon drops down a list of media players (similar to the submenu used to choose cameras)
  • Clicking a media player calls the set source and play media services behind the scenes.

There'd be no way to actually control the media playing on the device, though. But maybe that's okay.

@felipecrs
Copy link
Contributor Author

felipecrs commented Mar 5, 2022

There'd be no way to actually control the media playing on the device, though. But maybe that's okay.

Maybe, just maybe, the media_player reports the media currently being shown (which can be checked against the media used to start the stream). And there is the media_player.media_stop service for stopping it.

But certainly these two things (detect whether it's playing the given media or not), or stoping it, can be later enhancements.

@dermotduffy
Copy link
Owner

Start playing around with this, a few things:

  • I'm having initial difficulty getting Frigate media to play via HA remote playing at all (see bug above). If this is a real issue (and not just a problem on my side), that will become a required fix for this work.
  • There'll be limitations: I expect these things will work with it when it's done:
    • Clips
    • Snapshots
    • The camera entity ('HA' provider).
  • These things will not work with it:
    • Casting the card itself beyond the media (would need this instead).
    • Casting the jsmpeg (e.g. birdseye) or webrtc_card providers.

@dermotduffy
Copy link
Owner

Will be in v4.0.0 .

@github-actions github-actions bot locked and limited conversation to collaborators Oct 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants