Skip to main content
Aug 25, 2016 6:55 AM UTC
Question

How can we programmatically create device template in our own application?

It means we have our own Java Page and we want that we code here in such a way that device gets created based on this device template in Thingworx automatically.

Regards

Anupriya

    7 replies

    Sep 1, 2016 2:54 PM UTC

    I would think that you could leverage the Java SDK using an AppKey to do what you are looking to do.  More details might be helpful to ascertain this though.

    Sep 14, 2016 7:55 PM UTC

    What exactly do you mean by "device template" here?

    Sep 14, 2016 8:18 PM UTC

    Anupriya Agarwal​ So you want , rather than mapping a Virtual thing from Java SDK to a Remote Thing Created in Thingworx , You want Java SDK to be code din a way that it creates a Thing on Thingworx server Using specific template from Thingworx .

    Please let me know if I am able to phrase out your requirement correctly.

    aagarwalAuthor
    Sep 16, 2016 10:05 AM UTC

    Hi Ravi,

    Yes you have understood the right thing can you please help me with it

    Thnaks.

    Sep 16, 2016 12:25 PM UTC

    Anupriya Agarwal​ , Give me some time , I will try it out my self and will let you know .

    Rough idea about Steps being  involved :

    Making a Remote Thingworx Template with name like "TemplateToCreateThingsRemotely"

    Adding Service , which will automatically create a New Things based on this template.

    Calling this service from Java SDK.

    Sep 19, 2016 10:08 AM UTC

    Anupriya Agarwal​ , I tested this and its working.

    Steps

    Step 1 Create a new Template named as "TemplateForCreatingThingsRemotely" from Remote Template.

    Step 2  Add Service with Name "CreateThing"  with one input which would be name of  new Thing which will be created

    Example Script :

    var params = {

      name: NameOfThing /* STRING */,

      description: me.description /* STRING */,

      thingTemplateName: me.thingTemplate /* THINGTEMPLATENAME */,

      tags: me.tags /* TAGS */

    };

    // no return

    Resources["EntityServices"].CreateThing(params);

    Step 3 , Create a Thing Extending this newly created Template.

    Step 4 Test the Service .

    Now you need to call the service of first Thing which you have created from "TemplateForCreatingThingsRemotely".

    Sep 20, 2016 5:13 AM UTC

    Hi Anupriya,

    Additionally; you can create a Thing in composer with base Template as Remote Thing. Create all the properties and Services you want to have in the Remote Thing.

    Connect it with a Device; add all the bindings so that you have everything working in that Thing.

    Now you can create a Thing template from this Thing using the 'Create Thing Template' option in top right of the thing page in composer.

    Then you should delete this Thing and use this newly created Thing Template as Ravi Upadhyay​​ suggested.

    The service to create a Thing can be created separately under a Generic Thing to use the above created Thing Template as base for newly Created Remote Things.

    I hope it helps.

    Thanks,

    Ankit Gupta