cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

MQTT Template configuration not inherited in Things

SOLVED
Highlighted
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

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: MQTT Template configuration not inherited in Things

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;

View solution in original post

4 REPLIES 4

Re: MQTT Template configuration not inherited in Things

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

I could.

Re: MQTT Template configuration not inherited in Things

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;

View solution in original post

Re: MQTT Template configuration not inherited in Things

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.GetConfigurationTables();

    var len=tables.rows.length;

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

        var row=tables.rows;

        Things.SetMultiRowConfigurationTable({

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

            persistent: true,

            tableName: row.name

        });

    }

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________