How to script iterating through a loop and concentating a string

I have been given this amazing script by @le_top which iterates through your ZHA devices using ZHA Toolkit, but on each iteration it writes a line out to the log as the action, this is the relevant section:-

          - repeat:
              for_each: "{{ wait.trigger.event.data.devices }}"
              sequence:
                - service: system_log.write
                  data:
                    logger: zha_devices
                    level: error
                    message: >-
                      {{ "Name: %s, (%s) Power: %s dBm, Available: %s" % (
                      repeat.item.user_given_name, repeat.item.name,
                      repeat.item.rssi, repeat.item.available ) }}

Instead, I’d like to be able to concatenate the output into a single string that I can email.

Any assistance on how I might go about that would be gratefully received.

alias: Loop over zha_devices, extract some device data
sequence:
  - parallel:
      - sequence:
          - wait_for_trigger:
              - platform: event
                event_type: zha_devices_ready
          - service: system_log.write
            data:
              logger: zha_devices
              level: error
              message: "{{ \"Got event %s\" % ( wait.trigger.event.data.devices ) }}"
          - service: system_log.write
            alias: List unavailable only
            data:
              logger: zha_devices
              level: error
              message: >
                {% set ns = namespace(names=[]) %}
                {% for item in wait.trigger.event.data.devices if not item.available %}
                  {% set ns.names = ns.names + [ "'%s'" % (item.name) ] %}
                {% endfor %}
                Items: {{ ns.names | join(', ') }}
          - repeat:
              for_each: "{{ wait.trigger.event.data.devices }}"
              sequence:
                - service: system_log.write
                  enabled: false
                  data:
                    logger: zha_devices
                    level: error
                    message: >-
                      {{ "Item '%s' Power: %s dBm Available: %s" % (
                      repeat.item.name, repeat.item.rssi, repeat.item.available
                      ) }}
      - service: zha_toolkit.zha_devices
        data:
          event_done: zha_devices_ready
mode: single

Thank you once again.