How to set volume on Chromecast media player after turning it on?

The issue is that my Google Chromecast returns to 100% volume every time it’s turned on (from an Unavailable state).

I’ve tried setting an automation to trigger From: Unavailable, but it never triggers. I was able to get it to trigger From: off state, but action: media_player.volume_set doesn’t adjust the volume.

alias: aYamaha ON Volume Set
description: ""
trigger:
  - platform: state
    entity_id:
      - media_player.yamaha_receiver
    from: "off"
condition: []
action:
  - service: media_player.volume_set
    data:
      volume_level: 0.33
    target:
      entity_id: media_player.yamaha_receiver
mode: single

This looks like it should work, right? It does actually, but only if I manually run it. If I turn off the Chromecast, then turn it back on, it comes back at FULL VOLUME even though in HA it shows that it’s set to 0.33.

The real issue is that Chromecast automatically resets itself to 100% volume when it is powered on and doesn’t remember its last setting.

If you manually run it and it works then the action is ok.

If home assistant sets the volume to 0.33 when you toggle power to the device then the trigger is ok.

If home assistant is not actually changing the device then it may be that the chomecast is not fully ready to accept API commands right after turning on. Try this:

alias: aYamaha ON Volume Set
description: ""
trigger:
  - platform: state
    entity_id:
      - media_player.yamaha_receiver
    from: "off"
condition: []
action:
  - delay: 5
  - service: media_player.volume_set
    data:
      volume_level: 0.33
    target:
      entity_id: media_player.yamaha_receiver
mode: single

Mess around with the delay and see if you can get it to work consistently at the smallest value possible.

Thanks - great minds think alike - I tried different delay setting from a few seconds to 30secs - it’s still not adjusting the volume - it’s a puzzler. There shouldn’t be a difference between an automated action and me manually running it - but somehow there is.

media_player.yamaha_receiver is definitely your Chromecast entity_id and not your Yamaha amp?

Yep - it’s the Chromecast device. I really should come up with a better naming standard.

See if any of these work:

  - service: media_player.volume_set
    entity_id: media_player.yamaha_receiver
    data:
      volume_level: 0.33      

or

  - service: media_player.volume_set
    data:
      entity_id: media_player.yamaha_receiver
      volume_level: 0.33

Thanks for the suggestions - neither made a difference.

I’m going to accept at this time that there’s no simple solution - noteworthy though is that I have a Chromecast Audio that does “remember” its volume setting - so it’s probably a limitation of the Google app/integration.

I used to set the volume just before playing any audio on my (now replaced) Chromecast Audio devices. I don’t remember having any issue with it.

What happens if you (for tesing purposes) play a sound or tts message right after changing the volume (even if it is a 1sec silence recording)?

(right click “save audio as…”)

Also does the automation trace reveal anything weird?

I feel that I might be following in your footsteps. What did you replace them with? Sonos?

I’m doing my best to avoid Sonos.

I had my Chromecast Audio connected to a pair of Pebble USB speakers. I replaced the lot with this:

If you want to connect to an existing amp they have this:

Though I have no experience with it, if it is anything like the other Muse products it works extreemly well with Home Assistant.

This, returning to 100% is a new thing that is really annoying.
It didn’t use to be this way, I believe the change is in the Chromecast itself.

What I have done is wait for trigger, playing then added one second delay then set volume, delay two seconds set volume, delay again two seconds and set volume.
One of them usually finds its way to the Chromecast.

It’s quite annoying since we use the chromecast as the volume regulator and it should be around 50% when it’s normal.

Wow - reading up on this and watching their video now - this is what I’ve been looking for - I think.

The reason they have been out of stock is Home Assistant Users. There’s a review and tutorial here: Build Your Own Smart Home Speaker With ESPHome! - YouTube

Play a quick one second tone or silent clip, then change the volume. Here I do that to 2 speaker.

sequence:
  - parallel:
      - service: media_player.play_media
        target:
          entity_id: media_player.family_room_wifi
        data:
          media_content_id: media-source://media_source/local/bell_ding.wav
          media_content_type: audio/x-wav
        metadata:
          title: bell_ding.wav
          thumbnail: null
          media_class: music
          children_media_class: null
          navigateIds:
            - {}
            - media_content_type: app
              media_content_id: media-source://media_source
      - service: media_player.play_media
        target:
          entity_id: media_player.office_wifi
        data:
          media_content_id: media-source://media_source/local/bell_ding.wav
          media_content_type: audio/x-wav
        metadata:
          title: bell_ding.wav
          thumbnail: null
          media_class: music
          children_media_class: null
          navigateIds:
            - {}
            - media_content_type: app
              media_content_id: media-source://media_source
      - service: media_player.volume_set
        data:
          volume_level: 0.85
        target:
          entity_id: media_player.tts_announcements
1 Like

Ah, I had the oreder back-to-front.