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.23k stars 30.58k forks source link

Cast media_players missing attributes in 2021.12.2 #62054

Closed blueshiftlabs closed 2 years ago

blueshiftlabs commented 2 years ago

The problem

Google Cast media_player entities are missing the media_content_id, media_duration, media_position, and media_position_updated_at attributes, starting in 2021.12.2. After reverting to 2021.12.1, the attributes once again appeared

What version of Home Assistant Core has the issue?

2021.12.2

What was the last working version of Home Assistant Core?

2021.12.1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

cast

Link to integration documentation on our website

https://www.home-assistant.io/integrations/cast

Example YAML snippet

# Entity state from 2021.12.1:
volume_level: 0.4833333492279053
is_volume_muted: false
media_content_id: >-
  https://birdhouse-internal.blueshiftlabs.net:8123/local/sleep_music_tracks/Peaceful
  Slumber.mp3
media_duration: 3600.039184
media_position: 122.666175
media_position_updated_at: '2021-12-16T12:58:00.486776+00:00'
app_id: B45F4572
app_name: Home Assistant Media Player
entity_picture_local: null
friendly_name: Sleep Music Speakers
supported_features: 152335

# Entity state from 2021.12.2:
volume_level: 0.6500000953674316
is_volume_muted: false
app_id: 531A4F84
app_name: Home Assistant Media Player
entity_picture_local: null
friendly_name: Bedroom Mini
supported_features: 152333

Anything in the logs that might be useful for us?

No response

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

cast documentation cast source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @emontnemery, mind taking a look at this issue as it has been labeled with an integration (cast) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

emontnemery commented 2 years ago

Please share a log with these settings showing what happens when you start playing media:

logger:                      
  default: info              
  logs:                      
    homeassistant.core: debug
    homeassistant.components.cast: debug
    homeassistant.components.cast.media_player: debug
    pychromecast: debug
    pychromecast.discovery: debug
    pychromecast.socket_client: debug
blueshiftlabs commented 2 years ago

The determining factor seems to be what HA version started the cast, not which HA version is reading the attribute. I started media playback on 2021.12.1, and upgraded to 2021.12.2 while continuing playback, and the attributes appeared. When I turned off the media_player and cast again, the attributes did not appear.

emontnemery commented 2 years ago

Right. We do use a different method to start playing the media in 2021.12.2, maybe that's causing it. I can't reproduce it though, could you please share logs?

Also, I'm very puzzled about the app ID 531A4F84 with Home Assistant 2021.12.12. Have you made any local modifications? Do you have any custom components installed?

seanomat commented 2 years ago

Just want to chime in, that I see the same behaviour: https://community.home-assistant.io/t/chromecast-is-missing-attribute-media-content-id/367548/4

If media is playing during reboot the missing attributes seem to reappear. If I switch off the mediaplayer in HA, it stays in state "idle" even when I start playback again.

Not sure how to add the log, its 0.5 Mb so I guess copying it in here is out of the question.

EDIT: Added log, OMG it's written right there how to do this!

HA_chromecast log.txt

emontnemery commented 2 years ago

Not sure how to add the log, its 0.5 Mb so I guess copying it in here is out of the question.

zip it, then drag-drop the zip-file to a github comment 👍

blueshiftlabs commented 2 years ago

Here's the logs I collected. I disabled my custom_components temporarily just to rule out any interference on their part - it still reproduced without them, so it's not that.

Norien commented 2 years ago

I'm seeing this issue as well, had to revert to 2012.12.1

This is my template switch causing the issue


  - platform: template
    switches:
      white_noise:
        unique_id: white_noise
        value_template: >-
          {% if states.media_player.speaker.state != "playing" %} {% set state = "off" %} {% else %}{% set state = states.media_player.speaker.attributes.media_content_id %} {% endif %}
          {% set object = 'blizzard.mp3' %}
          {% if 'blizzard.mp3' in state %}on{% else %}off{% endif %}
        turn_on:
          - service: media_player.volume_set
            data:
              entity_id: media_player.speaker
              volume_level: 0.6
          - service: media_player.play_media
            data:
              entity_id: media_player.speaker
              media_content_id: "media-source://media_source/local/white_noise/blizzard.mp3"
              media_content_type: "audio/mp3"
        turn_off:
          - service: media_player.turn_off
            entity_id: media_player.speaker
fstap commented 2 years ago

Same for me. Additionally, the state of the cast device (Google nest mini in my case) doesn't go back to 'idle' after finishing playback. That worked before, now, a couple of automations are broken (they wait for the media player to reach the idle state to play some sounds sequentially). I'll add some logs tomorrow!

KoljaWindeler commented 2 years ago

Hi, thanks for your support @emontnemery, the cast integration is one of the most reliable integration that is out there and I'm using it multiple hours per day, every day. Great work :heart:

Unfortunately I see the same behavior:

Do you need another log file?

permissionBRICK commented 2 years ago

Same issue, it seems to be connected to the fact that Home Assistant is now using the Home Assistant Media Player App to cast media instead of the Default Media Player App. I need to read the currently playing url in order to determine the radio state and channel. Also, for future reference, i am casting to an NVIDIA Shield TV, and the URL I'm trying to cast is an internet radio livestream.

Heres the attributes I am seeing: volume_level: 0.8666666746139526 is_volume_muted: false app_id: B45F4572 app_name: Home Assistant Media Player entity_picture_local: null friendly_name: SHIELD supported_features: 152461

Edit: I just updated to 2021.12.3, issue persists

Arquiteto commented 2 years ago

Not sure it's connected, but my Google Nest Mini is stuck for the last 6 hours in 'playing' state, with the same attributes. On 2021.12.2 as well.

sj3fk3 commented 2 years ago

Not sure if it helps, but I use Google cloud TTS and a Google hub as media player. The automations waits until the player is Idle again before it plays the next (TTS) msg now it gets stuck for evah.. First one plays fine, then the player remains in "playing" mode.

rschuiling commented 2 years ago

Here's another log. My issue description: frontend attributes don't show up, as nicely described in #62288. And after playing a media file 1sec.mp3, the state stays on 'playing' for about 5 minutes then to 'off'. So no idle state.

ha_log_casting_issue.txt

Edit: forgot to mention this is core-2021.12.3

anthfarr commented 2 years ago

I have the same problem. Can confirm it happened from 2021.12.2 onwards

belgianrubs commented 2 years ago

Right. We do use a different method to start playing the media in 2021.12.2, maybe that's causing it. I can't reproduce it though, could you please share logs?

I'm not sure if it's caused by the cast integration because the attributes doesn't appear either when you cast from the Spotify app like I described in #62288 .

nov30th commented 2 years ago

I had a long time working my own Google Chromecast media player node-red media player

And current version 2021.12.3 stop working, I tried call services with Google mini, Google Nest, Google Tv, Group speakers in Developer Tools, the only working services are volume, on, off, mute. The background picture of the media player in UI also missing.