Martyn Bell
Martyn Bell

Reputation: 97

How can I populate event creation time in Azure IOT Central using python SDK

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

Upvotes: 0

Views: 233

Answers (1)

Roman Kiss
Roman Kiss

Reputation: 8235

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

Upvotes: 1

Related Questions