Trying to pull in a random value from a file in an automation
automations.yaml
- id: '1600991651680'
alias: TEST message
description: ''
trigger:
- platform: state
entity_id: cover.garage_door
to: open
for: 00:15:00
condition: []
action:
- data:
title: !include phrases_garage_door.yaml
message: ''
service: notify.mobile_app_my_iphone
mode: single
phrases_garage_door.yaml
>-
{{ [
"\U0001F698 Garage door is open flopen!",
"\U0001F698 Theives are happy, let's make them sad. Close the garage door.",
"\U0001F698 Close the door more porfavor"
]|random }}
This is what gets loaded automatically into the UI when I refresh, after adding the !include line into the automations.yaml
Looks good but when the automation runs it returns the name of the file include file instead of a random value from it. Very odd considering the UI is showing the contents of the include file.
The strings + random syntax works as I originally had that directly in the automation but want to separate the string values out so I can expand on them and call them from other places too rather than having them buried inside the automation itself.
The syntax above works in scripts but not in automations (where it just returns the name of the file instead of the value(s) from the file). So I went with a script instead which I can call from the automation.