Yes you will have to.
If you manually add a property to a Thing Template you have to save the changes. When a Thing Template is saved, all the Things with that Thing Template are automatically restarted. In this case, you are not saving so the Things are not restarting. Here is the improved generalized code snippet:
try{
Things["SimpleTest"].property = 5;
}catch(err){
var error=err.message;
if(error.match(/not found on SimpleTest/)!=null){
var params = {
defaultValue: undefined /* STRING */,
remoteBindingAspects: undefined /* JSON */,
description: undefined /* STRING */,
readOnly: undefined /* BOOLEAN */,
type: "NUMBER" /* BASETYPENAME */,
remote: undefined /* BOOLEAN */,
remotePropertyName: undefined /* STRING */,
timeout: undefined /* INTEGER */,
pushType: undefined /* STRING */,
dataChangeThreshold: undefined /* NUMBER */,
logged: undefined /* BOOLEAN */,
name: "property" /* STRING */,
pushThreshold: undefined /* NUMBER */,
dataChangeType: undefined /* STRING */,
category: undefined /* STRING */,
persistent: true /* BOOLEAN */,
dataShape: undefined /* DATASHAPENAME */
};
// no return
ThingTemplates["SimpleTestTemplate"].AddPropertyDefinition(params);
// no return
Things["SimpleTest"].RestartThing();
}
}
Kind regards,
Ezanne