Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
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 ?
Solved! Go to Solution.
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(); }
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(); }