Create and Import Models
20 min
a model defines the structure of a digital twin its static attribute placeholders, dynamic attribute fields, data transformations, topic expression parameters, and schema you create a model first, then create instances from it each instance inherits the model's structure and lets you fill in the real values for a specific physical asset note digital twins requires a scale or growth litmus license navigate to digital twins > models to access the models pane before you begin review digital twins docid\ xlj3gvozyg 52ue4pb5u7 to understand how models and instances relate before creating your first model create a model you can create a model from scratch or import one from a json file exported from another litmus edge instance create a new model to create a new model from the models pane, click the create a model tile the create a model dialog appears click the type drop down list and select a model type in the name field, enter a name for the model optionally, enter a short description in the description field optionally, select the uns enabled checkbox and select a uns connector from the drop down menu click add the new model tile appears in the models pane import an existing model to import a model exported from another litmus edge instance, click the import model icon, select the \<model name> json file, and click open model versions each model starts at version v 0 the version increments each time you save the model the current version appears on the model tile and on the model configuration page instances track which model version they were created from, which matters when you use upgrade instances to push model changes to existing instances model tile model and instance configuration page configure the model after creating the model, configure it with static attributes, dynamic attributes, transformations, parameters, and a schema model image click the upload image icon to add an image to the model tile this is visual only and does not affect how the model functions static attributes static attributes are fixed metadata fields such as manufacturer , plant , area , or device description in the model, you define the attribute names and set placeholder values each instance then overrides those placeholders with the actual values for the specific asset it represents to add static attributes from the static attributes tab, click the add item icon in the attribute name field, select an existing attribute from the drop down list or enter a new name in the attribute value field, enter a placeholder value import static attributes you can import static attributes from a csv file this is useful when you have many attributes or want to populate several instances at once before importing, create a csv file with the following headers required headers modelname key value optional header instancename (when included, the import sets attribute values directly on the named instance rather than on the model) to import static attributes navigate to static attributes and select import attributes in the dialog, navigate to and open the csv file export static attributes to export existing static attributes to a csv file for offline editing, navigate to static attributes and select export attributes dynamic attributes dynamic attributes represent real time data fields for the asset, such as temperature readings, current values, and pressure each dynamic attribute is mapped to a data topic in an instance, and the live data from that topic appears in the instance payload dynamic attributes support json, boolean, array, string, and number data types if you don't specify a data type, json applies each dynamic attribute can also reference a transformation schema to shape the data before it enters the payload to add a dynamic attribute click the add item icon in the name field, enter a name for the attribute optionally, enter a value in unit and select a data type if the data type is json, optionally select skip key to exclude the attribute key from the payload while keeping its value for example, the value persists as value='20' without the key name optionally, define a topic expression using static strings and parameter placeholders in curly brackets for example devicehub alias {device} tagname the {device} part is resolved per instance based on the instance's parameter value for device see configure parameters docid 0shkvwahcwyo4nyf0w00z below optionally, select a transformation schema from the schemaid field import and export dynamic attributes to import dynamic attributes, download the sample csv file, populate it with your attributes, then click the model tile, navigate to dynamic attributes , and click import attributes to export existing dynamic attributes to a csv file, click export attributes transformations transformations convert raw json data from a topic into a format that is easier for northbound systems to consume a transformation applies to a specific dynamic attribute, and the result replaces the raw data in the instance payload you can use two types json filters the payload to a specific set of key value pairs use this to strip unwanted fields from a data source jsonata applies conditional logic, computed values, and dynamic filtering using the jsonata https //docs jsonata org/overview\ html query language use this for alerts, computed outputs, or reformatting timestamps you can also use the following system variables in transformations {edge dt system time} , {edge dt model version} , and {edge dt model name} a playground in the transformation editor lets you test a schema against sample data before attaching it to an attribute to add a transformation schema click the transformation tab, then click the add a schema icon the add dialog appears enter a name for the schema from the schema type drop down menu, select json or jsonata in the code window, paste the json or jsonata schema optionally, select system variables from the code drawer to insert them into the schema use the playground to test the schema against sample data click add to edit or delete a schema, click the action menu for the schema and select an option apply the transformation to one or more dynamic attributes configure parameters parameters are named variables that you define in a model and set per instance they allow a single topic expression to resolve differently for each instance for example, define a parameter named device and use it in a dynamic attribute topic expression devicehub alias {device} temperature each instance then sets its own value for device , so the topic resolves to the correct tag for that specific machine note parameter names and values are case sensitive and cannot contain spaces allowed characters are uppercase and lowercase letters (a–z), digits (0–9), hyphens ( ), and underscores ( ) to create a parameter navigate to the parameters tab and click add item enter a parameter name and a placeholder value click save row add the parameter to a topic expression on a dynamic attribute for example, devicehub alias {device} temperature select an instance of the model and click open parameters in the instance parameters dialog, set the value for the parameter for that instance navigate to the instance dynamic attributes page to confirm the topic resolved correctly for that instance note when a dynamic attribute has a topic expression defined, the topic is not editable in the instance directly to change the topic, edit the model's topic expression or update the instance parameter value schema the schema tab lets you define a custom data structure for the model use it to group static and dynamic attributes into a named hierarchy for downstream systems that expect a specific json structure to create a schema click the action menu icon for root and select add node add attributes to the schema using either method drag attributes from the left hand list onto the canvas under the appropriate category click the action menu for a category and select add item to node , then select the attribute click save model additional schema options export schema export the current schema to a json file sync attributes appends all current attributes to the schema hierarchy the static attributes and dynamic attributes nodes are recreated if they already exist confirm the sync when prompted clear schema removes all nodes from the schema builder changes apply when you save the model apply model updates to instances when you update a model, existing instances do not automatically inherit the changes use upgrade instances to push model changes to selected instances to apply model updates click upgrade instances select the instances to upgrade and click upgrade next steps manage models docid\ hk0idxlg7zcoetajwcobo add an instance docid\ jzoth4t0hcrtrauusdryk manage instances docid\ req2rshywfuzlnezqls0t