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

Edge Java SDK Update multiple properties with writePropertiesVTQ

flucciarini
Participant

Edge Java SDK Update multiple properties with writePropertiesVTQ

I try to update multiple thing's properties with writePropertiesVTQ method.

Calling this method I find an error on apllication log

An Invalid Property Value Was Sent To [Random-Integer-Device1 Property: [null]

Thing name, properety name and value type is correct.

 

I'm setting up name, time, value and quality in ValueCollection and add it in an InfoTable

My code is

 

 

 

InfoTable it = new InfoTable();
NumberPrimitive np = new NumberPrimitive();
np.setValue("1.0");
ValueCollection vc = new ValueCollection();
vc.put("name", new StringPrimitive("propname1"));
vc.put("time", new DatetimePrimitive(new DateTime(new Date().getTime())));
vc.put("value", np);
vc.put("quality", new StringPrimitive(QualityStatus.GOOD.name()));
logger.info("Adding property propName1 with number value 1.0");
it.addRow(vc);
np = new NumberPrimitive();
np.setValue("2.0");
vc.put("name", new StringPrimitive("propname2"));
vc.put("time", new DatetimePrimitive(new DateTime(new Date().getTime())));
vc.put("value", np);
vc.put("quality", new StringPrimitive(QualityStatus.GOOD.name()));
logger.info("Adding property propName2 with number value 2.0");
it.addRow(vc);
client.writePropertiesVTQ(ThingworxEntityTypes.Things, "thingName", it, 10000);

 

 

 

 

What is wrong? How can I use writePropertiesVTQ? How can I update multiple properties at time with specify device reading time?

 

Thanks

5 REPLIES 5

Re: Edge Java SDK Update multiple properties with writePropertiesVTQ

Hi @flucciarini , An Invalid Property Value Was Sent To . This error occurs when you have not defined the remote properties on the platform side which you are updating or when they are inaccurately configured on the platform.

Re: Edge Java SDK Update multiple properties with writePropertiesVTQ

Thank you for reply

 

The entire error message is

An Invalid Property Value Was Sent To [Random-Integer-Device1 Property: [null]
 
So I need to create remote thing and remote properties to use writePropertiesVTQ method?

Things on platform are manage from another develop group and they haven't create remote thing. 

How can I update multiple properties at time setting up reading time with java sdk ?

The only method is with remote thing?

Re: Edge Java SDK Update multiple properties with writePropertiesVTQ

Hi @flucciarini ,If you are using a VirtualThing on the edge we generally recommend VirtualThing::setPropertyVTQ() + VirtualThing::updateSubscribedProperties().

BaseClient::writePropertiesVTQ() is invoking the UpdatePropertyValues service on the Thing.

 


DataShapeDefinition ds = new DataShapeDefinition();
ds.addFieldDefinition(new FieldDefinition(CommonPropertyNames.PROP_NAME, BaseTypes.STRING));
ds.addFieldDefinition(new FieldDefinition(CommonPropertyNames.PROP_TIME, BaseTypes.DATETIME));
ds.addFieldDefinition(new FieldDefinition(CommonPropertyNames.PROP_QUALITY, BaseTypes.STRING));
ds.addFieldDefinition(new FieldDefinition(CommonPropertyNames.PROP_VALUE, BaseTypes.VARIANT));

InfoTable propertyValues = new InfoTable(ds);
ValueCollection row = new ValueCollection();

row.put(CommonPropertyNames.PROP_NAME, new StringPrimitive("p1"));
row.put(CommonPropertyNames.PROP_TIME, new DatetimePrimitive(DateTime.now()));
row.put(CommonPropertyNames.PROP_QUALITY, new StringPrimitive(QualityStatus.GOOD.name()));
row.put(CommonPropertyNames.PROP_VALUE, new StringPrimitive("toto"));
propertyValues.addRow(row);

client.writePropertiesVTQ(ThingworxEntityTypes.Things, "TESTThing", propertyValues, 1000)

 

In general we define remote thing and property on thingworx side and map them to the edge property.

 

Defining the property.

 

@ThingworxPropertyDefinition(name = "Blob_STR", description = "The device humidity",
        baseType = "BLOB",
        aspects = { "dataChangeType:NEVER", "cacheTime:0",
                "isPersistent:FALSE", "isReadOnly:FALSE", "pushType:ALWAYS"})

Sending the property.

 

String blobData = "AFAFAFAAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
this.setPropertyValue("Blob_STR", new BlobPrimitive(blobData.getBytes()));
super.updateSubscribedProperties(5000);

 Let me know your use case if it is different.

Re: Edge Java SDK Update multiple properties with writePropertiesVTQ

Hi @flucciarini , Regarding the multiple property updates you can follow this .

 

https://www.ptc.com/en/support/article/CS221424 

Re: Edge Java SDK Update multiple properties with writePropertiesVTQ

Hello @flucciarini 

 

If you feel your question has been answered, please mark the previous response as the Accepted Solution for the benefit of others with the same question.

 

Thanks

Om Dukiya

Announcements

Check out the upcoming Expert Session: Understanding ThingWorx Navigate Licensing in Community "Customer Events" section.