How to define an actuator model for a device and using in Azure Iot Central

GuidoL 310 Reputation points
2023-04-26T17:48:46.63+00:00

Hi,

i'm not sure if i'm following a corret strategy to implement an actutator for my project: this is not very clear in Microsoft documentation:

i defined the following model to command a device (starting from library rfid ontology i defined..)

[
  {
    "@id": "dtmi:digitaltwins:org:archive:download:rfidsmartlibrary:RfidSmartLibraryowl:RfidTagAlarmCodeOnOffKioskActuator;1",
    "@type": "Command",
    "contents": [
      {
        "request": {
          "@type": "CommandPayload",
          "name": "RequestParam",
          "displayName": {
            "en": "RequestParam"
          },
          "schema": {
            "@type": "Object",
            "fields": [
              {
                "displayName": {
                  "en": "CommandAutoReadWriteData"
                },
                "name": "CommandAutoReadWriteData",
                "dtmi:dtdl:property:schema;2": {
                  "@type": "Enum",
                  "enumValues": [
                    {
                      "enumValue": "AUTO_READ_DATA",
                      "name": "AUTO_READ_DATA"
                    },
                    {
                      "enumValue": "AUTO_WRITE_DATA",
                      "name": "AUTO_WRITE_DATA"
                    }
                  ],
                  "valueSchema": "string"
                }
              },

              {
                "displayName": {
                  "en": "CmdDeactivateAntenna"
                },
                "name": "CmdDeactivateAntenna",
                "dtmi:dtdl:property:schema;2": {
                  "@type": "Enum",
                  "enumValues": [
                    {
                      "enumValue": "OFF",
                      "name": "OFF"
                    },
                    {
                      "enumValue": "On",
                      "name": "On"
                    }
                  ],
                  "valueSchema": "string"
                }
              },

              {
                "displayName": {
                  "en": "CmdStart"
                },
                "name": "CmdStart",
                "dtmi:dtdl:property:schema;2": {
                  "@type": "Enum",
                  "enumValues": [
                    {
                      "enumValue": "OFF",
                      "name": "OFF"
                    },
                    {
                      "enumValue": "On",
                      "name": "On"
                    }
                  ],
                  "valueSchema": "string"
                }
              },

              {
                "displayName": {
                  "en": "TagAFICheckActivated"
                },
                "name": "TagAFICheckActivated",
                "dtmi:dtdl:property:schema;2": {
                  "@type": "Enum",
                  "enumValues": [
                    {
                      "enumValue": "OFF",
                      "name": "OFF"
                    },
                    {
                      "enumValue": "On",
                      "name": "On"
                    }
                  ],
                  "valueSchema": "string"
                }
              }
            ]
          }
        },

        "response": {
          "@type": "CommandPayload",
          "name": "ResponseParam",
          "displayName": {
            "en": "ResponseParam"
          },
          "schema": {
            "@type": "Object",
            "fields": [
              {
                "displayName": {
                  "en": "CommandAutoReadWriteData"
                },
                "name": "CommandAutoReadWriteData",
                "dtmi:dtdl:property:schema;2": {
                  "@type": "Enum",
                  "enumValues": [
                    {
                      "enumValue": "AUTO_READ_DATA",
                      "name": "AUTO_READ_DATA"
                    },
                    {
                      "enumValue": "AUTO_WRITE_DATA",
                      "name": "AUTO_WRITE_DATA"
                    }
                  ],
                  "valueSchema": "string"
                }
              },

              {
                "displayName": {
                  "en": "CmdDeactivateAntenna"
                },
                "name": "CmdDeactivateAntenna",
                "dtmi:dtdl:property:schema;2": {
                  "@type": "Enum",
                  "enumValues": [
                    {
                      "enumValue": "OFF",
                      "name": "OFF"
                    },
                    {
                      "enumValue": "On",
                      "name": "On"
                    }
                  ],
                  "valueSchema": "string"
                }
              },

              {
                "displayName": {
                  "en": "CmdStart"
                },
                "name": "CmdStart",
                "dtmi:dtdl:property:schema;2": {
                  "@type": "Enum",
                  "enumValues": [
                    {
                      "enumValue": "OFF",
                      "name": "OFF"
                    },
                    {
                      "enumValue": "On",
                      "name": "On"
                    }
                  ],
                  "valueSchema": "string"
                }
              },

              {
                "displayName": {
                  "en": "TagAFICheckActivated"
                },
                "name": "TagAFICheckActivated",
                "dtmi:dtdl:property:schema;2": {
                  "@type": "Enum",
                  "enumValues": [
                    {
                      "enumValue": "OFF",
                      "name": "OFF"
                    },
                    {
                      "enumValue": "On",
                      "name": "On"
                    }
                  ],
                  "valueSchema": "string"
                }
              }
            ]
          }
        }
      }
    ],

    "@context": [
      "dtmi:iotcentral:context;2",
      "dtmi:dtdl:context;2"
    ],
    "description": {
      "en": "Rfid Tag Alarm Code On/Off Kiosk Actuator"
    },
    "displayName": {
      "en": "Rfid Tag Alarm Code On/Off Kiosk Actuator"
    },
    "extends": "dtmi:digitaltwins:org:w3id:rec:core:OnOffActuator;1"

  }
]


so if i try to import it in ADT Model i receive the following output:

*** Uploading selected models
- working on RfidTagAlarmCodeOnOffKioskActuator.json

but i can't find the model after import also there aren't no errors; i don't know if it's correct define an actuator in this way to command my library Rfid Kiosk device.

In case i'm wrong can you suggest a correct way to simulate command to my twins of library rfid device (in this case i need to command a self server kiosk that disables/enbles rfid alarm code if library item have correct borrow/return procedure)? An example of using actuator with Azure Iot Central for my goal is welcome.

Thanks in advance.

Guido

Azure Digital Twins
Azure Digital Twins
An Azure platform that is used to create digital representations of real-world things, places, business processes, and people.
219 questions
Azure IoT Central
Azure IoT Central
An Azure hosted internet of things (IoT) application platform.
342 questions
{count} votes

Accepted answer
  1. Roman Kiss 2,241 Reputation points
    2023-04-26T21:37:49.0433333+00:00

    Hi @GuidoL

    You can use the Azure IoT Central for creating a DTDL model of the Rfid Kiosk device and then export it.

    Thanks

    Roman

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 13,456 Reputation points
    2023-04-26T21:02:16.5266667+00:00

    Hi @GuidoL Greetings! Thank you for posting the question here. To be able to better assist you with the designing the model template, could you please share more details on the functioning of your actuator, different properties/telemetry data it may transmit. Apologies if those does not apply to the actuator model you are trying to implement. My knowledge on the device is limited.

    Inspecting the model, you have shared, it implies that the model has a request command which takes in a schema of type object as payload and a response command. The model does not have any telemetry or properties. Does this seem accurate to what you are trying to accomplish?

    Looking at the model templates provided in the samples of the GitHub, I would say the template type should be interface and the "type@" : "Command" should be embedded within the contents section of the interface. Kindly refer to the template of TemperatureController-2.json as the sample provides an example of Command with a CommandPayload.

    Let us know if the above information is helpful and please reach out with further questions in the comments below.

    1 person found this answer helpful.
    0 comments No comments