Can't we use a template in a list

might seem silly but this is the first time I’ve ran in to this, trying to have an entity_id list with a template entity_id and normal entity_id:

    sequence:
      - service: tts.google_say
        data_template:
          entity_id:
            - media_player.googlehome_master_bedroom
            - {{states('sensor.media_player')}}

but this seems to not be possible?

dev-template shows the template itself is correct:

—Edit—

wait, multiline… > added and now config checks fine…

      - service: tts.google_say
        data_template:
          entity_id: >
            - media_player.googlehome_master_bedroom
            - {{states('sensor.media_player')}}

still doesn’t work though, no error in the logs.

This will work

      - service: tts.google_say
        data_template:
          entity_id:
            - media_player.googlehome_master_bedroom
            - "{{states('sensor.media_player')}}"

or this

      - service: tts.google_say
        data_template:
          entity_id:
            - media_player.googlehome_master_bedroom
            - >
              {{states('sensor.media_player')}}
2 Likes

cool, never seen that before.

so use the multiline from the entity_id that needs that. or use the quote, which I am not a fan of…
learned somethings today again!
thank you sir.

Indeed, this is very cool.
How am I ever going to remember all the obscure coolness I see on these forums?

This is just understanding yaml and it’s format. Once you fully understand how lists and dictionarys work in yaml, you’ll know where/how to use the > and templates. I’m sure there is some yaml tutorials out there that will help you guys more that I can.

you’re doing very well :wink:

sometimes its not just Yaml though, but also HA behaving unexpectedly, as I am experiencing with my other quest right now, using the templated time trigger. Perfect Yaml, even the config check accepts it, and even at startup, no error os thrown.

Still doesn’t work…Need template to automate this volume increase

Well that’s cause you can’t template in that field. Good rule of thumb, if the word “template” isn’t in the field or in the parent field, you won’t be able to use templates. Also, you can’t simply add the word template and expect it to work, it wont. You can only place templates into template designated fields.

sure, I understand, read the docs etc. still feels unexpected, given the many people asking for that. Maybe an extra + on the feature request would help.

templated time trigger, or time trigger template. doesn’t get better than that.

oof, variable time triggers would be very hard to implement because the time determines when automations will trigger. Templates resolve after a trigger/change has occurred. So you’re in a “which comes first, chicken or egg” scenario.

1 Like

so you say that even if this looks the same:

because of the fact the template has to be evaluated first, and needs a time cycle for that, things become flakey? That would be too bad really, looks so attractive.

I would have thought that talking machine language these 2 would have been identical, merely using another representation.

Seems I would be forced to use @123’s suggestion for a timer after all…

What happens when you change the time? That’s the problem. Yeah the configuration may look the same, but when the timing changes realtime what comes first?