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

Dynamically changing the Configuration property of a Thing

SOLVED
Level 4

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
Highlighted

Re: Dynamically changing the Configuration property of a Thing

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(); }
1 REPLY
Highlighted

Re: Dynamically changing the Configuration property of a Thing

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(); }