0

As the title says, I am wanting to populate the event creation time per event sent. This is in case of a break in communications I can continue to store data locally and then send when connection is available.

IOT CENTRAL

Then when I look at the dashboard view the data is populated correctly. Has anyone had any experience doing this ? Thanks

  • have a look at my answer in the https://stackoverflow.com/questions/55243977/provide-timestamp-in-message-to-iot-central – Roman Kiss Nov 01 '21 at 10:11

1 Answers1

1

The following code snippet shows an example of sending a telemetry data for specific component:

# Send a telemetry data for thermostat2 component
print("Sending message...")
msg = Message(json.dumps({"temperature":25.12345}))
msg.content_encoding = "utf-8"
msg.content_type = "application/json"
msg.custom_properties["iothub-creation-time-utc"] = "2021-11-01T12:15:00.123Z"  
msg.custom_properties["$.sub"] = "thermostat2"
await device_client.send_message(msg)
print("Message successfully sent!")

the Raw data on the IoT Central App: enter image description here

Roman Kiss
  • 7,925
  • 1
  • 8
  • 21
  • Thank you for that. From the tutorials I've seen I wasn't sure if I could used the from azure.iot.device.Message class to send my events as. My first test from your example worked perfectly. – Martyn Bell Nov 01 '21 at 15:01