Help please with calendar value template automation

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 }}"

And the yaml for the full automation is:

alias: Cal test event
description: ''
trigger:
  - platform: calendar
    event: start
    offset: '0:0:0'
    entity_id: calendar.name_gmail
condition:
  - condition: template
    value_template: '"{{ ''Cal test event'' in trigger.calendar_event }}"'
action:
  - service: light.turn_on
    data:
      rgb_color:
        - 28
        - 34
        - 217
      brightness: 185
    target:
      entity_id:
        - light.guy_s_pc
        - light.guys_monitor
mode: parallel

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?

You have too many quotes.

value_template: '{{ "Cal test event" in trigger.calendar_event }}'

Thanks, but still no dice. I amended the entry in yaml directly to minimise the chance of extra quotes being added. So in yaml I have

value_template: '{{ "Cal test event" in trigger.calendar_event }}'

And in the visual editor I have

{{ "Cal test event" in trigger.calendar_event }}

Same error message when I test that section: template value should be a string for dictionary value @ data[‘value_template’]. Got None

What are you doing to test the automation?

At the moment it’s just set to turn a couple of lights on at my desk.

That is the action. How do you trigger the automation?

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:

Executed: 2 June 2022, 13:00:00
Result:

result: false entities:

You need to specify you are looking at the value associated with the summary key.

value_template: "{{ 'Cal test event' in trigger.calendar_event.summary }}"

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 }}

Thanks, both, for the help.