Maintain a list of random phrases as a helper or template?

I’m looking to maintain a list of Greetings and Departing messages I can use to give my house some personality. I’d use this in Push messages and Audio Notifications.

Right now, I have the list in a text doc on my computer in the below format and copy/paste when creating an automation or script. I don’t love this obviously because I’d need to maintain these lists in a million places every time I add or refine the list.

{{ ['Sayonara!', 'Enjoy the world out there.', 'Have fun, Ill keep things running while youre gone.'] | random }}

Is there a way to maintain these lists within a helper or a template so that I can simply reference them in automations/scripts and have the result return a random phrase?

You can utilize the new macro functionality.

Make this file (and folder)

config/custom_templates/phrases.jinja

{% set departing = [
  'Sayonara!',
  'Enjoy the world out there.',
  'Have fun, Ill keep things running while youre gone.'
] %}

Then wherever you want to use it

{% from 'phrases.jinja' import departing %}
{{ departing | random }}
6 Likes

Thanks @petro - I’ll give this a whirl later today!

This is great. Works a charm! Thanks @petro

1 Like

Or try ChatGPT?

This yaml gives me todays weather forecast in different styles randomly:

styles:
    - happy
    - upbeat
    - motivational
    - funny
    - epic
    - dark humor
    - polite

so it is different every time :grin:

it will be easy to adept it to say greetings/goodbye

@aceindy admittedly, as I posted this ask this morning, I realized I was asking for something that is probably obsolete already. ChatGPT certainly seems like the more scalable and better option for the long term…

Aceindy
tell give me a short welcome home in a happy way using 2 lines?


ChatGPT
"Welcome back, sunshine! Home is brighter with your joyful presence."

“Welcome home! Our hearts dance with joy as you grace our doorstep once more."

Failed to mention earlier that I AM using ChatGPT to generate my list of phrases with a prompt like:

generate a list of uplifting phrases your house would say to you as you leave and put them in single quotes separated by commas.
1 Like