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=""
    <!--Data can be sent for many sensors -->
       <!-- a list of data is provided per sensor -->
           <!-- the key for this metadata -->
           <!-- the value for this metadata -->
      <!-- ISO 8601 format date/time of the metadata for this sensor -->
      <Timestamp>{{ now().timestamp() | timestamp_custom('%Y-%m-%dT%H:%M:%S') } </Timestamp>

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="" xmlns:xsi=""><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>