Dynamically set input select

Have an automation that based on zones ,
zone is quite dynamic in my use case as i keep adding zones to HA.
so i’d like to find away to allow this automation work more dynamically with zone .

i.e:

input_select:
  waze_origin:
    name: waze_origin
    options:
      - group.zones

    initial: zone.home
  waze_destination:
    name: waze_destination
    options:
      - group.zones

Not sure how it can be accomplish but is there a way to dynamically set input select options?
I tried grouping by zone and use zone group in the input_select,
but grouping by zone is not allowed


group:
  zone_for_waze:
    name: zone use for waze
    entities: >
       {{ states.zone | map(attribute='entity_id') | reject('walk', '.*outside*.') | join(',') }}

@krskrab

Please stop posting AI generated nonsense. None of the configuration variables in an Input select accept templates. It’s fine to use AI sources, but if you actually want to be helpful take 5 minutes and test the output in your own instance before posting it… otherwise you’re just wasting other people’s time and making Home Assistant seem harder than it is.


Use a Template Select entity instead of an Input Select helper.

I don’t think this alone will actually solve your issue… but you may be able to use it.

You can create groups based on a template if you use the group.set service and set up an automation. You will need to include restart as one of the triggers for the automation since these dynamic groups do not survive restart. You may wish to create a zone count template sensor to use as a second trigger so that your group updates when you add or remove zones.

Regarding your template, you have specified a non-existent test in your reject filter. There is no test called ‘walk’. In the following I assume that you meant to exclude the entity zone.walk as well as any zone with an entity id containing the word “outside”. If that is not the case, please clarify what you are trying to do.

service: group.set
data:
  object_id: select_zones
  name: Group of Zones for Select entity
  entities: >
    {{ states.zone | map(attribute='entity_id')  
    | reject('eq', 'zone.walk')
    | reject('match', '.*outside*.') | list }}
2 Likes

AI generated templates have proven to be a good source of amusement. This latest example succeeds in showing the most inefficient way to select a few entities from a specific domain.

Hot Tip for the AI: if the goal is to extract zone entities, start by filtering states.zone and not all entities in the State Machine.

It explains why Stackoverflow banned the posting of AI-generated “solutions”. The results tend to be “confidently incorrect” (or merely clumsy).

1 Like

Actually dont see how AI generated template relevant here but i understand your point,
regards the tip.
correct if i wrong but is not the way to filter out zone only:

{{ states.zone | map(attribute='entity_id') 
    | reject('match', '.*outside*.') 
    | reject('eq', 'walk') | list }}

Taras was referring to the nonsense AI generated response posted by krskrab.

Also, I have edited my original comment because I neglected to include the domain in the second reject filter.