4 Replies Latest reply on Aug 8, 2017 5:52 PM by jborovský RSS
    jborovský Newbie

    MQTT Template configuration not inherited in Things

    Hi,

    I am trying to create several MQTT Things( connection+subscriber +publisher) and I would like to be able to add new MQTT Things in javascript.

    I ve created a MQTT Template (from MQTT) with connection to network server etc., properties, and automatic mapping from topic.

    While in Template view, I can click create Thing in top right, then the configuration appears in the new Thing as well(desired).

     

    But when creating or cloning Thing in javascript, the configurationis is not copied.

    I use Thingworx 7.1.

     

     

    Any ideas how to solve it or explanations?

    Thank you in advance.

    Jaroslav

      • Re: MQTT Template configuration not inherited in Things
        carko Creator

        Hello, Jaroslav.

         

        Could you export the template you're using and attach it here?

         

        Thanks,

         

        -- Craig A.

        • Re: MQTT Template configuration not inherited in Things
          drichter Explorer

          I had the same problem. You must copy the config from mqtt to your new thing.

           

          Create script:

          // create thing

          // enable thing

          // restart thing

           

          // copy the mappingtable to the new thing

          var mappingTable = me.CopyMappingTable();

           

          var params = {

              configurationTable: mappingTable,

              persistent: true,

              tableName: "Mappings"

          };

           

          Things[Name].SetMultiRowConfigurationTable(params);

            

          // copy the connectioninfotable to the new thing

          var connectionInfoTable = me.CopyConnectionInfo();

           

          var params = {

              configurationTable: connectionInfoTable,

              persistent: true,

              tableName: "ConnectionInfo"

          };

            

          Things[Name].SetMultiRowConfigurationTable(params);

           

          // restart thing again

           

          CopyMappingTable-Service:

           

          // return "Mappings"-table

          var params = {

              tableName: "Mappings"

          };

           

          // result: INFOTABLE

          var connectionInfoTable = me.GetConfigurationTable(params);

           

          result = connectionInfoTable;

           

          CopyConnectionInfo-Service:

           

          // return "Infotable"-table

          var params = {

              tableName: "ConnectionInfo"

          };

           

          // result: INFOTABLE

          var mappingTable = me.GetConfigurationTable(params);

           

          result = mappingTable;

            • Re: MQTT Template configuration not inherited in Things
              jborovský Newbie

              Thank you for your help. Thats what I needed.

              Just adding my more concise version.

               

              Get config tables from A template to B thing

               

              var tables = ThingTemplates[A].GetConfigurationTables();

                  var len=tables.rows.length;

                  for(var i=0;i<len;i++){

                      var row=tables.rows[i];

                      Things[B].SetMultiRowConfigurationTable({

                          configurationTable: ThingTemplates[A].GetConfigurationTable({tableName: row.name}),

                          persistent: true,

                          tableName: row.name

                      });

                  }