Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Translate the entire conversation x

Bind property tags programatically

HaiderZia
3-Newcomer

Bind property tags programatically

Hi Everyone,

 

I'm trying to write a service that can bind properties in my thing to data in an edge device. here's my code:

 

 

 

// get all properties from the thing
propertyDefs = Things[assetThing].GetPropertyDefinitions({
category: undefined /* STRING */,
type: undefined /* BASETYPENAME */,
dataShape: undefined /* DATASHAPENAME */
});
numberOfProperties = propertyDefs.getRowCount();

var params = {
infoTableName: "PropertiesToAdd" /* STRING */,
dataShapeName: "PropertyNamesForBindings" /* DATASHAPENAME */
};
var allProperties = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

for each(var property in propertyDefs.rows){
// Only add properties starting with "Fan"
if (property.name.substr(0,3) == "Fan"){
var newRow = new Object();
newRow.name = property.name;
newRow.description = "";//property.description;
allProperties.AddRow(newRow);
}
}

// loop through properties, and add source to each property.

sourceNamePrefix = edgeChannelName + "." + edgeDeviceName + "." ;

for each (var prop in allProperties.rows){
Things[assetThing].SetRemotePropertyBinding({
propertyName: prop.name /* STRING */,
sourcePropertyName: sourceNamePrefix+prop.name /* STRING */,
timeout: undefined /* INTEGER */,
pushType: undefined,
pushThreshold: 0.1 /* NUMBER */,
aspects: undefined /* JSON */,
cacheTime: undefined /* INTEGER */,
foldType: undefined
});
}

Things[assetThing].RestartThing();

 

 

 

Before this, I would go to manage bindings tab on the thing and drag and drop the tags in KepserverEX onto the properties in my thing. Using that method shows the tag like in the screenshot below:

 

HaiderZia_0-1607821311683.png

 

However when I run my service, the tag looks like this and doesnt get the data from the edge:

HaiderZia_1-1607821364237.png

 

Any ideas how this can be fixed? The tags are added but the data doesnt come through. 

Thanks.

 

ACCEPTED SOLUTION

Accepted Solutions
anarwal
13-Aquamarine
(To:HaiderZia)

3 REPLIES 3
anarwal
13-Aquamarine
(To:HaiderZia)

HaiderZia
3-Newcomer
(To:anarwal)

Thanks. This helped.

slangley
23-Emerald II
(To:HaiderZia)

Hi @HaiderZia.

 

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

 

Regards.

 

--Sharon

Announcements


Top Tags