SIA Event(s) to display Sensor

I have the below template sensor but cant work out why it does not work, i must have the syntax wrong somewhere although it is accepted the confgauration.yaml it doesnt work. Any ideas?

template:

  • trigger:
    • platform: event
      event_type: sia_event_1468_AAA
      event_data:
      code: BR
      message: “2”
    • platform: event
      event_type: sia_event_1468_AAA
      event_data:
      code: BA
      message: “2”
      sensor:
    • name: garagedoor
      state: >
      {% if trigger.platform.event_data.code(‘BA’) %}
      Open
      {% if trigger.platform.event_data.code(‘BR’) %}
      Closed
      {% endif %}

Anyone got any ideas?

Anyone any help at all?