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.

Hi,

Did you ever find a (programmatic) way to compensate for the Chromecast volume maxxing out upon restart?

The Google Home app must send some code to the Chromecast when we touch the volume dial. There should be a way to emulate that GH behavior in HA, right?

I have a bunch of chromecast audios that drive my whole house audio system. They are hooked to amps directly, so the chromecast audio controls the volume. HA controls the volume just fine. What are you trying to do that doesn’t work?

My installation is similar to yours. A few days ago I introduced a Chromecast 3 and a CCWGTV (ie not CCAs) with audio extractors feeding amps (as the video outputs feed monitors).

Which is when I discovered that whenever those CCs reboot (e.g. further to a f/w update) their volume level is set to 100% wreak!ng havoc on my eardrums :frowning: CCAs do NOT exhibit such a behavior.

However HA (or any UPnP client for that matter) does NOT see the full volume: it actually indicates the CC volume is what it was prior to the device”s restart !!

The only way you can revert the volume from full to acceptable is through the Google Home app (or with the CCWGTV remote).

As a restarted CC is blaring into the amp, its control dial in the GH app still shows the CC’s pre-restart volume (just like HA). As soon as you touch the dial, the physical level reverts to its pre-restart volume.

Which is why I was hoping someone had looked at the commands the GH app was sending the CC to that affect so we could have HA emulate them.

Does what I’m saying make sense?

Ok, I think I understand the issue. The right answer is to get CCA’s from ebay and replace the chromecast. :slight_smile:

Part of the issue is that the regular chromecasts are video devices, and meant to feed receivers where the volume controls control the volume. That is the default config for HDMI. Are your audio extractors programmable with regards to volume level? I have some units on my TV’s that understand the HDMI CEC commands from the HDMI source, and use that as an input to a switch that switches my WHA zone from the CCA to the TV out. If you have CEC enabled, I am pretty sure that reset of HDMI volume doesn’t happen.

The other thing you can use is to use HDMI audio extractors that have IR volume control capability, and use a cheap Tuya IR emitter to control the volume that way. There is a clever blueprint that Volume Automation for Chromecasts reads volume changes from the chromecast and then turns them into commands to a receiver (or HDMI audio extractor) to actually change the volume.

In any case, trying to use a non-CCA as a CCA is a kludge, and you will probably spend more money and time trying to make that solution work than buying a CCA. :slight_smile:

1 Like

Thanks for your assessment and recommendations :grinning:

I also use quite a few CCAs so I won’t argue with you about their qualit!es. I added the two regular CCs b/c I wanted to listen to synchronized audio through amp/speakers when I watch movies on PC monitors that have poor audio (i.e. no TV, no CEC). Plus i also want to cast / listen to music using the same amp/speakers while keeping the monitors on standby.

Unfortunately my audio extractor volume can’t be controlled. I just use an IR-controlled powered HDMI splitter to make sure the monitors receive no signal when I terminate movie casting so they go into standby mode (otherwise they’d continuously display the CC ambient mode pics!).

I took a look at the blueprint you mention, however it’s based on HA somehow being “aware” that the CC volume has just been maxxed out. The trouble is when the HA interface queries a post-restart “blaring” CC, the volume it reads is not 100% but the pre-restart level. Nor can it “force” the CC volume. Only the Google Home app (or the CCWGTV remote) can allow you to set the CC in a mode that accepts volume commands again.

I guess I’ll take a look at IR-controlled extractors on the market. Unless someone identifies the magic command that the GH app uses to take CCs out of blaring mode :smiley:

I totally concur with your ‘kludge warning’.

Thanks again for your time.