home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.19k stars 30.57k forks source link

Casting music to group of Chromecast Audio players does not change state of those players #8531

Closed fanaticDavid closed 5 years ago

fanaticDavid commented 7 years ago

Home Assistant release (hass --version): 0.48.1 (0.49.0 doesn't contain any changes to the Google Cast component)

Python release (python3 --version): 3.4.2

Component/platform: Media player: Google Cast

Description of problem: When casting to a group of Chromecast Audio players, the state of the individual players never changes: all involved Chromecast Audio players remain off.

Expected: The state of every Chromecast Audio player should change, just like it does when casting to an individual Chromecast Audio player.

Problem-relevant configuration.yaml entries and steps to reproduce:

media_player:
  - platform: cast
    host: 192.168.xxx.xx
  - platform: cast
    host: 192.168.xxx.xx
  - platform: cast
    host: 192.168.xxx.xx
  - platform: cast
    host: 192.168.xxx.xx
  1. Add Chromecast Audio players to your Home Assistant setup
  2. Create a group of 2 or more Chromecast Audio players in the Google Home app (Android)
  3. Cast music to that group from the Spotify app (Android)
  4. Watch the Chromecast Audio players remain off in Home Assistant

Additional info: I'm not using the discovery component, all my Chromecast Audio players are added to my configuration manually. Other users have reported the same issue in this thread on the forum.

point-4ward commented 7 years ago

A chromecast group shows as a player of its own in my setup, which shows correctly playing when casting to it. This is identical behavior to the Google music app, and therefore I suspect it is just how the platform works.

You may not see the group player in your setup as you have individually assigned each player in your configuration, and you obviously can't define an ip address for the 'group' as it is effectively virtual.

Try removing all the guff from your configuration and see if the group player appears....

media_player:
  - platform: cast 

As I say, I expect this is a limitation on how chromecast groups work and not something that home assistant can do anything about.

Hope this helps.

fanaticDavid commented 7 years ago

I just had a closer look at what happens in the Google Home app:

This somewhat matches up with the behaviour in Home Assistant which you described. So I took your suggestion and stripped my config down to what you suggested, and behold: the group player made an appearance.

I edited my automations to deal with this additional player, so that should fix the issue I had (it's past 2:00 AM over here so I can't test it right now). It's not quite what I expected, but I think it's good enough for what I want to do.

Thank you very much, @mf-social ! You were very helpful! 😁

fanaticDavid commented 7 years ago

I'm reopening this issue because there are use cases in which the workaround above doesn't help. An example can be found on the forum here:

The difference is that in the google home app it shows playing. In HA it shows off. The problem here is that you can’t adjust the volume for an individual player in the group. In Google Home app you can adjust the volume synchronized for all players just like in HA, but you can also adjust the volume individual. Because the players is in off-state HA can’t adjust the volume. I have an automation looking like this:

action:
  service: media_player.volume_set
  entity_id: media_player.vaggen
  data_template:
    volume_level: '{{ states.media_player.vaggen.attributes.volume_level + 0.05 }}'

This won’t work because the state of that player is off when using multiroom.

tinmice commented 7 years ago

I've written a few automations in appdaemon to get around it, which have helped but it doesn't quite solve the problem fully.

I have a card that has a slider for each chromecast and a sensor returning the volume of each one as well, the idea being that the automation keeps them in sync/updates them as required. When casting to a group the media_player.volume_set will actually change the volume on the chromecast, even though homeassistant thinks that it is off. This only then leaves the problem of obtaining playing or volume information from individual chromecast devices when casting to a group (as the group has one averaged value).

Would be great to be able to access the playing information for each one individually, as someone pointed out, the Google Home app still allows you to see some of the basic info even when casting to a group.

sti0 commented 6 years ago

I've got another problem. All my players are visible at HA. Normally when I cast to a group the group player got status playing and shows cover art. Sometimes the group player isn't showing in HA that he's playing. In the google home app the player is playing. After a HA restart the group player shows it's correct state in HA. I have some trigger on the group state, this automations won't work reliable.

OttoWinter commented 6 years ago

See https://github.com/balloob/pychromecast/issues/111 - this is probably quite hard to fix

balloobbot commented 6 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

xydix commented 6 years ago

I have the issue mentioned in the forum. But i am still on V0.64.3 due to the new python requirered. Can't test right now. Sorry. Anyone can test if the player in a group show the right state? If i remember right it just showed off and i couldn't adjust the volume on the specific player, only the group volume.

balloobbot commented 6 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

SteveDinn commented 5 years ago

This is still an issue for me. I'd love to have a solution.

almostserious commented 5 years ago

I'd also like to understand the issue. Ideal case for me would be: All the devices of a group that actual play content (as seen in Google Home App) will be seen as "playing" within Home Assistant and report their volume etc. What is the reason for them to be shown as off? A limitation within pychromecast? Or was this a choice for usability?

SteveDinn commented 5 years ago

I've since noticed that when playing video from the Facebook Android app or Facebook website in Chrome on the desktop, the chromecast shows as being 'off' despite actively playing video. This isn't an 'audio groups' thing, so I'm not sure it's related, but the symptoms are identical.

balloobbot commented 5 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

almostserious commented 5 years ago

Issue is still there. Behaviour has not changed.

finish06 commented 5 years ago

Considering this has been recognized as a substantial undertaking above, consider adding a conditional volume slider. If group A (with speakers 1 & 2) is playing, show volume sliders for speakers 1 & 2.

tangrick commented 5 years ago

I just started learning python and trying to understand home assistant component few weeks ago. So please forgive me if I am doing something wrong and I know my solution is definitely not idea but it fixed my problem of having to go to google home app to control individual speakers, it is painful because it takes many steps to reach them. So after many hours of modifying and trial and errors on working on python and the cast media player component.

This was what I did, I overridde Cast (I know overriding HA media player cast component is NOT recommended and is Bad practise) but I just want to use this as a temporary solution until the expert here provide us the best solution.

So this was what I did, just in case...I might be in the right path

First I force all chromecast to always idle, since only then I could control the volume when it is idle. I did try to use chromecast.status.display_name or app_name (can't remember) to determine whether it is playing to change the STATE but when STATE_OFF my volume slider has weird characters. So in the end I just made it simple for myself STATE_IDLE always.

    @property
    def state(self):
        """Return the state of the player."""
        if self.media_status is None:
            return None
        if self.media_status.player_is_playing:
            return STATE_PLAYING
        if self.media_status.player_is_paused:
            return STATE_PAUSED
        if self.media_status.player_is_idle:
            return STATE_IDLE
        if self._chromecast is not None and self._chromecast.is_idle:
            return STATE_IDLE   # it was STATE_OFF
        return None 

I can't remember but I believed without wait() the volume sometime return as null or no volume..and caused error..so I added this

    @property
    def volume_level(self):
        """Volume level of the media player (0..1)."""
        self._chromecast.wait()   # added a wait for device to be ready
        return self.cast_status.volume_level if self.cast_status else None

And now all my google devices (I have many)... mini, home and hub have volume control and I am using (thomasloven/lovelace-slider-entity-row) on HA.