Error when setting property value to a created thing
I am trying to create an extension, which provides a Template having a service for dynamic custom thing creation.
After installing the extension and creating a Thing from the extension template, i am executing the createThing service. I am successfully able to create the Things dynamically using the below code, however my property is not getting updated.
public static void createSomeThing(DeviceNode node) throws Exception {
String thingName = "MT-" + node.getName();
Thing deviceThing = ThingUtilities.findThing(thingName);
if (deviceThing == null) {
deviceThing = ThingTemplateUtilities.createThingFromTemplate("MyTemplate", thingName, node.getName(), true);
}
deviceThing.EnableThing();
deviceThing.RestartThing();
if (deviceThing.GetValueStream() == null) {
String streamName = thingName+"Stream";
Thing deviceVS = ThingTemplateUtilities.createThingFromTemplate(
"ValueStream", streamName, "Value stream for " + node.getName(), true);
deviceVS.EnableThing();
deviceVS.RestartThing();
deviceThing.SetValueStream(streamName);
}
deviceThing.setPropertyValue("DeviceName",
new StringPrimitive(node.getName() + "-" + node.getUuid()));
}
This is how the Thing is defined:
@ThingworxBaseTemplateDefinition(name = "GenericThing")
@ThingworxPropertyDefinitions(properties = {
@ThingworxPropertyDefinition(name = "DeviceName", description = "", category = "", baseType = "STRING", isLocalOnly = false, aspects = {"dataChangeType:VALUE", "isReadOnly:true", "isLogged:true" }) })
public class MyTemplate extends Thing {
// Some basic stuff
}
I get the below error in the logs once the service is executed.
2018-05-17 14:27:59.957+0530 [L: ERROR] [O: c.t.t.Thing] [Device03] [U: Administrator] [S: ] [T: http-nio-8080-exec-9] Attempt To Write Property [DeviceName] Failed - Thing Not Running 2018-05-17 14:27:59.957+0530 [L: WARN] [O: c.t.t.Thing] [I: ] [U: Administrator] [S: ] [T: http-nio-8080-exec-9] Thing [Device03] has logged properties but does not have a valid value stream assigned
Please help on how to resolve the above error.

