Help with escape characters in template

I’m trying to write an action with an event template. Without the template, the event looks like:

- event: homeassistantCube
  event_data:
    notifications: [{title: 'Goodnight security', severity: 'warning', options: {detail: 'All is well... sleep tight', dismissable: 'true'}}]

I would like to add the following into the above as a random integer: {{ range(1,99999) | random }}}, so the event would look something like:

- event: homeassistantCube
  event_data_template:
    notifications: [{title: 'Goodnight security', severity: 'warning', options: {detail: 'All is well... sleep tight', dismissable: 'true', serverId: {{ range(1,99999) | random }} }}]

I know the above is incorrect, but I cannot figure how to escape it properly. Can any Jinja ninjas help me out?

J.

Why do you say that? I just copied and pasted it into the Template Editor and it seems to work fine. Are you seeing an error somewhere?

EDIT: Actually, you may be right. You could try:

- event: homeassistantCube
  event_data_template:
    notifications: [{title: 'Goodnight security', severity: 'warning', options: {detail: 'All is well... sleep tight', dismissable: 'true', serverId: '{{ range(1,99999) | random }}' }}]

or:

- event: homeassistantCube
  event_data_template:
    notifications:
    - title: Goodnight security
      severity: warning
      options:
        detail: All is well... sleep tight
        dismissable: 'true'
        serverId: "{{ range(1,99999) | random }}"

That did the trick… thank you!