Set up a device template
A device template is a blueprint that defines the characteristics and behaviors of a type of device that connects to a Microsoft IoT Central application.
For example, a builder can create a device template for an IoT connected fan that has:
Temperature telemetry measurement
Fan motor error event measurement
Fan speed setting
Rules that send alerts
Dashboard that gives you an all up view about the device
From this device template, an operator can create and connect real fan devices with names such as fan-1 and fan-2. All these fans have measurements, settings, and properties, rules, and a dashboard that users of your application can monitor and manage.
Only builders and administrators can create, edit, and delete device templates. Any user can create devices in the Device Explorer page from existing device templates.
Create a new device template
Navigate to the Application Builder page. Make sure you switch on builder mode in the left navigation menu.
When builder mode is switched on, you can build device templates and customize the home page. To make changes to a specific device, turn off builder mode.
To create a blank template, choose Create Device Template, and then choose Custom.
Enter a name for your new device template and choose Create.
Now you’re on the Device Details page of a new simulated device. A simulated device is automatically created for you when you create a new device template. It reports data and can be controlled just like a real device.
When builder mode is switched on, making changes to the Device Details page of any device edits its device template. When builder mode is off, making changes to the Device Details page of any device changes values in that specific device.
Now look at each of the tabs on the Device Details page.
Measurements are the data coming from your device. You can add multiple measurements to your device template to match the capabilities of your device. Currently, telemetry and event are the types of supported measurements.
- Telemetry measurements are the numerical data points your device collects over time and are represented a continuous stream. For example, temperature.
- Event measurements are point-in-time data that represent something of significance on the device. Events have severity associated with them that represents the importance of the event. For example, fan motor error
Create a Telemetry measurement
To add a new telemetry measurement, click on + New Measurement button that opens up a form with choices to select the measurement type. Select Telemetry and enter the details on the Create Telemetry form.
When a real device is connected, pay attention to the name of the measurement the device reports. The name must exactly match the Field Name of a measurement.
For example, you can add a new temperature telemetry measurement:
After you choose Save, the Temperature measurement appears in the list of measurements and an operator can see the visualization of the temperature data the device is collecting.
Create an Event measurement
To add a new Event measurement, click on + New Measurement button that opens up a form with choices to select the measurement type. Select Event and enter the details on the Create Event form.
On this form provide the Display Name, Field Name, and the Severity of the event. You can choose from the three available levels of severity - Error, Warning, and Information.
For example, you can add a new 'Fan Motor Error' event.
After you choose Save, the Fan Motor Error measurement appears in the list of measurements and an operator can see the visualization of the event data the device is sending.
To view additional details about the event, click on the event icon on the chart:
Settings control a device. They enable operators of your application to provide inputs to the device. You can add multiple settings to your device template that appear as tiles on the Settings tab for operators to use. There are six types of settings you can add: number, text, date, toggle, pick list, and section label.
When a real device is connected, pay attention to the name of the setting the device reports. The name must exactly match the Field Name of a setting.
Settings can be in one of three states. These states are reported by the device.
Synced: the device has changed to reflect the setting value.
Pending: the device is currently changing to the setting value.
Error: the device has returned an error.
For example, you can add a new fan speed setting:
After choosing Save, the Fan speed setting appears as a tile and is ready for to be used to change the fan speed of the device.
After you create a new tile, you can try out your new setting. First, switch off builder mode in the left navigation menu:
Properties are the device metadata associated with the device, such as device location and serial number. You can add multiple properties to your device template, which appear as tiles on the Properties tab. An operator can specify the values for properties when they create a new device, and they can edit these values at any time. There are six types of properties you can add: number, text, date, toggle, device property, and label.
There are two types of properties:
- Device properties are properties reported by the device.
- Application properties are properties stored purely in the application. The device has no knowledge of application properties.
For device properties, when a real device is connected, pay attention to the name of the property the device reports. The name must exactly match the Field Name of the property. For application properties, the field name can be anything you want, as long as the name is unique in the device template.
For example, you can add device location as a new property:
After choosing Save, device location appears as a tile:
After creating a new tile, you can change the property value. First, switch off builder mode in the left navigation menu.
Rules enable operators to monitor devices in near real time. Rules automatically invoke Actions such as sending an email when the rule triggers. There is one type of rule available today:
- Telemetry rule: A telemetry rule triggers when the selected device telemetry crosses a specified threshold. Learn more about telemetry rules.
The dashboard is where an operator can go to see information about a device. As a builder, you can add tiles to this page that help operators understand how the device is behaving. You can add multiple dashboard tiles to your device template. There are six types of dashboard tiles you can add: image, line chart, bar chart, KPI, settings and properties, and label.
For example, you can add a Settings and Properties tile to show a selection of the current values of settings and properties:
Now when an operator views the dashboard, they can see this tile that displays the properties and settings of the device:
Now that you have learned how to set up a device template in your Microsoft IoT Central application, here is the suggested next step: