Hello all templaters.
I’ve finally gotten so far in my configuration of my Hassbian that I’m not confident in a lot of my sensors and all of them work without problems, so now I’m starting to be more adventurous.
Enter Jeeves -the Facebook notify component and now my personal housekeeper.
I have a notify component configured, and a 13 different automations, sending multiple messages to me every day when I leave the house, enable Guest-mode when people I don’t want to annoy are around and at such simple events as when the sun has set, like this:
#Jeeves actions
- alias: 'Jeeves Sundown - Evening Greeting'
trigger:
- platform: sun
event: sunset
action:
- service: notify.jeeves
data:
message: !include response_texts/jeeves_evening_greeting.yaml
target:
- 'HIDDEN_PHONE_NUMBER'
It works - and brilliantly so. But let’s say I want to add to the script, building sentences nested, such as including random messages with a different message depending on the time of day.
I already have a file with the different messages scripted in, based upon Phil Hawthornes brilliant guide to building your own J.A.R.V.I.S.:
Contents of jeeves_evening_greeting.yaml
{% if now().strftime("%H")|int < 12 %}
Good morning, Sir.
{% elif now().strftime("%H")|int < 18 %}
Good afternoon, Sir.
{% else %}
Good evening, Sir.
{% endif %}
But say I want to randomize the message even more. Say I want to call me a random name instead of “Sir”.
So I’ve tried adding an included yaml file in the configuration like this
{% if now().strftime(“%H”)|int < 12 %}
Good morning, {{ !include response_texts/jeeves_friendly_names.yaml }}
Contents of jeeves_friendly_names.yaml:
{{ [
"Sir",
"Master Wayne",
"Sire"
] | random }}
... But that just results in a message saying exactly that:
Messenger:
Good morning, {{ !include response_texts/jeeves_friendly_names.yaml }}
It would seem like the file isn’t parsed right because the script doesn’t compile includes in an already included file.
So my questions:
- Is there a way to parse nested includes?
- Is there a way to build sentences with different content based upon sensors like time and states?
- Can it be automated?
- How do I use multiple !includes in a single sentence without breaking it up?