MQTT publish an XML format with timestamp

Hi there,

just got MQTT now configured with SSL. i’ve been using it for a while to receive data, but now i’m looking to publish data out in a specific XML format that another system parses. I’ve done some manual tests in MQTT explorer and the built in MQTT publish a packet section and everything checks out there.

now i’m trying to figure out how to get this to work over the mqtt.publish service.

if i send this message through the MQTT configure section in the payload, it works fine, but is it possible to send this in the payload_template of the mqtt.publish? the Dev tools section doesn’t seem to allow the XML. anyone have thoughts?

<MainMetaData xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SensorList>
    <!--Data can be sent for many sensors -->
    <SensorMetaData>
       <!-- a list of data is provided per sensor -->
      <MetaDataList>
        <MetaData>
           <!-- the key for this metadata -->
          <Key>person_detected</Key>
           <!-- the value for this metadata -->
          <Value>true</Value>
        </MetaData>
      </MetaDataList>
      <Id>1</Id>
      <!-- ISO 8601 format date/time of the metadata for this sensor -->
      <Timestamp>{{ now().timestamp() | timestamp_custom('%Y-%m-%dT%H:%M:%S') } </Timestamp>
    </SensorMetaData>
  </SensorList>
</MainMetaData> 

figured it out. just needed to make it a single line. and it doesn’t seem to care about the quotes. when i tried to escape them, the \ escape character still passed through. So, just made it one line and it works

topic: MY_TOPIC
payload_template: <MainMetaData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SensorList><SensorMetaData><MetaDataList><MetaData><Key>person_detected</Key><Value>true</Value></MetaData></MetaDataList><VehicleId>1</VehicleId><Timestamp>{{ now().timestamp() | timestamp_custom('%Y-%m-%dT%H:%M:%S') }}</Timestamp></SensorMetaData></SensorList></MainMetaData>