Enhancement Request: Please update `sonos.snapshot` & `sonos.restore` to use targets instead of entity_id

I’m heavily using the actions sonos.snapshot and sonos.restore for triggers like restore after watching tv, or after ringing the doorbell, ect, so no one has to understand how to restore every in the Sonos app…

First observation

When using the sonos.snapshot or sonos.restore actions, it is quite strange that you have to use the keyword all see documentation .
But selecting all in the UI is not an option.

So why can’t the sonos.snapshot and sonos.restore assume all when nothing is selected?

Second observation

When running:

action: sonos.snapshot
metadata: {}
data:
  with_group: true

a log entry is created with :

ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140107998447872] Error handling message: must contain at least one of entity_id, device_id, area_id, floor_id, label_id.. Got {'type': 'execute_script', 'sequence': [{'action': 'sonos.snapshot', 'data': {'with_group': True}}], 'id': 785} (invalid_format)

and so if I trigger:

action: sonos.snapshot
metadata: {}
data:
  with_group: true
  floor_id:
    - first_floor
    - second_floor

Then it works :smiley:

Please update these two actions/services to utilize targets Selectors - Home Assistant which removes all of the guess work

The value all is commonly used by other Home Assistant actions to indicate all entities in the same domain (i.e. light.turn_on).

That action’s configuration is missing what it should snapshot. As for the with_groupoption, its default value is true so it’s unnecessary to explicitly include it.

Right, because now it specifies what it should snapshot (all eligible media_player entities on the specified floors).

If you’re referring to how the UI presents selecting targets for sonos.snapshot (currently limited to
just entity_id) then UI-related Feature Requests are submitted to Github in Home Assistant’s Frontend repository (the forum’s FR section is for non-UI requests).

1 Like

If you’re referring to how the UI presents selecting targets for sonos.snapshot (currently limited to
just entity_id) then UI-related Feature Requests are submitted to Github in Home Assistant’s Frontend repository (the forum’s FR section is for non-UI requests).

Which selectors are used for integration services is actually not a frontend concern. Each integration in core defines in services.yaml what selectors they want to show for each field.

So if you want a more complex selector than entity_id, that would be decided in the sonos core component. So this is the correct location for this request.

Thank you, I wasn’t aware of that.

So what must be added here to make it work the way Grumblezz wants?

snapshot:
  fields:
    entity_id:
      selector:
        entity:
          integration: sonos
          domain: media_player
    with_group:
      default: true
      selector:
        boolean:

So what must be added here to make it work the way Grumblezz wants?

It would likely take more than just changes here, also changes in the integration code itself that handles these inputs, but if you want a target selector I guess replacing selector: entity: with selector: target: would be a first step.

1 Like

Thanks! Looking at that file then I immediately see also other various issues, which shows that there are more service not working as expected. Like setting the alarm ect. The selector should be in the following format:

selector:
    target:
      entity:
        - integration: sonos
          domain: media_player

I created a new issue: Update the sonos.snapshot and sonos.restore actions to allow other targets then entity_id · Issue #145885 · home-assistant/core