How to improve tts script with variable

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This makes it easier to find for users with similar questions.

For more information refer to guideline 21 in the FAQ.


I don’t know what you read in the variables documentation that led you to believe you can define a variable like that but you can’t.

This is the correct format. However it still won’t work the way you want because of the scope of variables.

      - variables:
           entities: media_player.office_speaker

What are all the conditions that will determine which media_players to use? It may be possible to use a template instead of if-then-else.