Is there a simple way to get a list of all of the custom sentences I’ve created as triggers for various automations? As the list grows I find myself (and my family) forgetting what we’ve built custom sentences for or what exactly the syntax is that we used.
It would be cool to create a dashboard page that lists them all out dynamically, but even if there’s just a simple way to “find” them all and print them out/save them, that would be helpful.
Just after I read your post I stumbled on this one. Maybe it can form a basis of what you need? I haven’t delved far.
Alternatively, does the Spook add-on help?
Thanks for both suggestions. I might try out the Entity Manager but the description doesn’t seem to suggest it can go find and list out automation triggers. Spook seems … big! I’m only part-way through trying to understand what it does and it may well offer the functionality I’m after, but it seems to be a rather substantial integration. I’ll have to digest that a bit more before I commit to installing it.
I guess the simple answer to my question is just to look in my automations.yaml file - I can certainly scroll through that to find “trigger: conversation” entries and then copy out the “command” that’s been recorded. For my current purposes, at least, that seems viable.
jtf
Create a py script, for example, in the file editor. Then run it in the terminal. python3 config/find.py.
import yaml
import sys
FILE_PATH = '/homeassistant/automations.yaml'
try:
with open(FILE_PATH, 'r', encoding='utf-8') as f:
automations = yaml.safe_load(f)
if not automations:
print("File is empty")
sys.exit()
for auto in automations:
triggers = auto.get('triggers', [])
if isinstance(triggers, dict):
triggers = [triggers]
for t in triggers:
if t.get('trigger') == 'conversation':
cmd = t.get('command')
if cmd:
if isinstance(cmd, list):
for c in cmd:
print(c)
else:
print(cmd)
except FileNotFoundError:
print(f"{FILE_PATH} not found.")
except ImportError:
print("err PyYAML")
except Exception as e:
print(f"err: {e}")
Legacy YAML voice automations, if you created them, are stored in /homeassistant/custom_sentences