I’m hoping to update my old calendar configuration to use the new features now added. But I’m stuck with the value template syntax.
I have a google calendar of calendar.name_gmail and a test event titled “Cal test event”. I want to trigger an action when that event comes around. Building this using the visual editor, the entry for the template in the visual editor looks like this:
"{{ 'Cal test event' in trigger.calendar_event }}"
But when I test the condition template I get an error “template value should be a string for dictionary value @ data[‘value_template’]. Got None”
I’ve tried variations of around ’ and " at start / end of the line and around the the event title but always get the same error message. I’ve also tried stripping out both the ’ that are being added in the yaml view and leaving those, stripping out the ’ or " that I’ve typed in the visual editor. Nothing seems to work though so the automation fails. What am I doing wrong?
Ah, sorry. I have a 1 hour appointment in the calendar with the title Cal test event. I’m modelling this on the example given in the integration docs. When a given event starts, do the action.
If the event has already started then it wont trigger.
You need to add an event in the future (I assume, I have not used this, but that is how usually automations have to work)
Yes, I’ve been moving the appointment back through the morning whilst testing different variants on the syntax. The trace for the most recent attempt started at 1300, as it should have, and then errors at the value template:
Thanks, this plus an ongoing oddity with quotes plus a reboot seems to have done it. When I looked at the description of trigger.calendar_event I assumed it meant the title. But the following yaml seems to be working:
value_template: '{{ ''Cal test event'' in trigger.calendar_event.summary }}'
For some reason using a double quote around “Cal test event” doesn’t work, but a pair of single quotes before and after does. I don’t think I’m ever going to understand the logic of templates!
In the visual editor it presents as this, which should be easy enough to replicate elsewhere:
{{ 'Cal test event' in trigger.calendar_event.summary }}