Correct format for multiple mqtt payloads at once

Would you please help me to have the correct syntax for the following script? I want to publish different payloads for the same topic.

   - service: mqtt.publish
       - data:
           topic: Home/RF/RESULT
           payload: 4E7511
       - data:
           topic: Home/RF/RESULT
           payload: 667511

Thanks for your help

I don’t know if there is another more compact way of doing it but you can just have multiple service calls of the same service with different data:

- service: mqtt.publish
  data:
    topic: Home/RF/RESULT
    payload: 4E7511
- service: mqtt.publish
  data:
    topic: Home/RF/RESULT
    payload: 667511

Thanks for replying! That’s what I ended up doing. I didn’t know if there was a more concise way.

I believe there is more than one :wink:
For example, you can use events.
i.e create an automation that accepts payload, something like this:

- alias: event_publish
  initial_state: true
  trigger:
    - platform: event
      event_type: publish_my_payload
  action:
    - service: mqtt.publish
      data_template:
        topic: Home/RF/RESULT
        payload: "{{ trigger.event.data.payload }}"

and then wherever you need to publish to that topic, call

- event: publish_my_payload
  event_data:
    payload: 4E7511

Great! That’s a great way to make concise maintainable code. I really appreciate your input.