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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Dynamically changing the Configuration property of a Thing

AjaySrini
6-Contributor

Dynamically changing the Configuration property of a Thing

Can someone advise me if there is a way to change the configuration property of a thing dynamically (through a service).

 

My requirement is as follows :

 

I have a thing (Thing_1) that inherits TimerThing Template and in the Configuration tab, there is an 'Update Rate' set as 60000ms by default. Now, I need to change this configuration property dynamically from a service of another thing (Thing_2) based on the input provided to that service.

 

Is there any in-built service that I can use to update the configuration property dynamically ?

1 ACCEPTED SOLUTION

Accepted Solutions

Here you have a code sample on how to do it:

 

// -- Parameters
var timerName = "yourTimerThingName";
var updateRate = 60000; // or anyother

// -- Constants var CONFIGURATION_TABLE_NAME = "Settings"; // -- Start var timer = Things[timerName]; if (timer!=null) { var actualValues = timer.GetConfigurationTable({ tableName: CONFIGURATION_TABLE_NAME }); if (actualValues.rows.length>0) { actualValues.rows[0].updateRate = updateRate; var params = { configurationTable: actualValues , persistent: true, tableName: CONFIGURATION_TABLE_NAME }; // no return timer.SetConfigurationTable(params); } // -- A Full Restart it's needed, just doing a Disable/Enable doesn't works timer.RestartThing(); }

View solution in original post

1 REPLY 1

Here you have a code sample on how to do it:

 

// -- Parameters
var timerName = "yourTimerThingName";
var updateRate = 60000; // or anyother

// -- Constants var CONFIGURATION_TABLE_NAME = "Settings"; // -- Start var timer = Things[timerName]; if (timer!=null) { var actualValues = timer.GetConfigurationTable({ tableName: CONFIGURATION_TABLE_NAME }); if (actualValues.rows.length>0) { actualValues.rows[0].updateRate = updateRate; var params = { configurationTable: actualValues , persistent: true, tableName: CONFIGURATION_TABLE_NAME }; // no return timer.SetConfigurationTable(params); } // -- A Full Restart it's needed, just doing a Disable/Enable doesn't works timer.RestartThing(); }
Top Tags