Scene on the fly does not record media_player volume (or restore afterwards)

issue: Scene on the fly does not record media_player volume (or restore afterwards) · Issue #141986 · home-assistant/core · GitHub

essentially this is recording the state of a few lights (state/color/brightness) and media_players (volume)

      - action: scene.create
        data:
          scene_id: voor_oprit_detectie
          snapshot_entities: >
            {{union(label_entities('alarm_lamp'), ['media_player.alarm_players'])}}

(note this is done with the new union list template option in 2025.4 beta and identical to other template options like

{{label_entities('alarm_lamp') + 
  state_attr('media_player.alarm_players','entity_id')}}

# or

{{label_entities('alarm_lamp') + ['media_player.alarm_players']}}

executing some intermediary action (and upping the volume)

and then restore the previously restored lights/media_players states.

      - action: scene.turn_on
        target:
          entity_id: scene.voor_oprit_detectie

everything works, not errors in the logs, but the media_players remain on the adjusted volume level which is set in the intermediate action.

cant this be done?
Given nothing nis documented particularly on volume level, I filed the above issue, but this seems the more appropriate spot to add comments or suggestions, so please if you know what to do, or what this cant be done, Id appreciate the feedback

I can of course reset the volume manually, but that would be killing the elegance of the scene on the fly.

update
seems the volume is not available when the players are ‘off’… I can only manually reset because of that.
Not sure if that is a FR, and not a plain issue… the volume is set on those players, as is obvious when starting playing without setting a volume level first. They use their recorded volume level from before that play action.

anyways, ive added that to the issue above, hope to get some feedback there.

I just tried this out using dev tools on a media player that was playing and it does restore the volume however, it also restarts the playlist (when using Music Assistant at least). I got excited here for a minute as I have a rather involved script to restore media player volumes after TTS announcements and other various events and thought I might be able to replace it with on the fly scenes. The playlist restarting is a deal breaker for me though. But it does work (volume restore).

thx for confirming (volume_level is restored if its available)

that is a completely different usecase form mine though. I practically never play music over these devices, only use them for notifications and stuff. so they’re mostly silent and Not playing.

thats when this happens:

so, restoring does not touch the volume level in that case…

vote for my FR then :wink:

Volume level should always be available if your media player supports it. It seems this is an issue with your media player, not with scenes.

EDIT: Just noticed you said “when off”. Yes, this is just like lights with brightness.

so basically this means the scenes on the fly record attributes only when these entities are ‘on’ and contain their attributes (color, brightness, volume…)

I hadn’t realized that because my scripted lights always contain data to set those too.

Guess I have to revisit the on the fly creation to only contain states, and not attributes.
Which makes it a rather moot technique in my usecase.

Though the volume is set and remembered on the device somehow. Wish that could make it into a feature to restore with the scenes

The problem is, the state of your media player is off. If you resume that state, it doesn’t matter what the volume is because the media player will turn off.