We have not heard from you for a long time, Hope you have found an answer to your query.
If not, In addition to the above response. See the below suggestions which might help you with your scenario.
We have more or less 100 types of alarm, and depend on the device, the alarm code will change, the device which is connected to Azure is esp32, so if it is possible we want to send the alarm code to save the memory and let the server side to parse the value, and if it is possible, we also want to map the value depend on the id field, for example,
{"id":x, "alarms":[2]} if the id is 0 then 2 means "Emergency stop", if the id is 1 then 2 means "High temperature".
You could try creating a property graph that maps the "alarms" JSON array to individual properties. For example, you could create properties named "Alarm 1", "Alarm 2", "Alarm 3", etc., and map the values of the "alarms" array to these properties. This would allow you to display each alarm separately on your dashboard.
Here's an example of how you can define a device template that includes an "alarms" telemetry property with mappings for the alarm codes:
{
"$schema": "https://azureiotcentral.com/schemas/1-preview/device-template.json",
"contents": {
"devices": {
"<device-template-id>": {
"displayName": "<device-template-display-name>",
"description": "<device-template-description>",
"telemetry": [
{
"name": "alarms",
"displayName": "Alarms",
"type": "Object",
"mapping": {
"type": "map",
"fields": [
{
"name": "1",
"displayName": "Alarm 1"
},
{
"name": "2",
"displayName": "Alarm 2"
},
{
"name": "3",
"displayName": "Alarm 3"
},
{
"name": "4",
"displayName": "Alarm 4"
}
// You can add more mappings as needed till 100 in your case
]
}
}
]
}
}
}
}
In the above example, the "alarms" telemetry property is defined as an object with a mapping type of "map", which allows you to define a set of key-value pairs for the alarm codes and their corresponding display names. You can add more mappings as needed to support your 100 types of alarms.
Once you have defined your device template, you can use it to create a device in Azure IoT Central and start sending telemetry data with the "alarms" property set to a JSON object containing the alarm codes. For example:
{
"alarms": {
"1": true,
"2": true,
"3": false,
"4": false
}
}
This will send an "alarms" telemetry message indicating that alarms 1 and 2 are active, and alarms 3 and 4 are inactive.
Hope this helps you to get started and succeed in achieving your scenario.
Feel free to comment in the below section for further help in this matter.