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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

QueryImplementingThingsWithNamedPropertyHistory

SP_9715784
11-Garnet

QueryImplementingThingsWithNamedPropertyHistory

When  QueryImplementingThingsWithNamedPropertyHistory is used in my script I am getting data of all the PUMPS data available on the dashboard, but I need only One Pump data in PIVOT and Code goes like this: 

 

var PropertyName = "PumpRunSignal";

if(PumpName === undefined || PumpName === null || PumpName === '' ) {
var query = undefined;
}
else{

var query = {
"filters": {
"type": "EQ",
"fieldName": "name",
"value": PumpName
}
};

}


var result2 = ThingTemplates["PumpThingTemplate"].QueryImplementingThingsWithNamedPropertyHistory({
propertyNames: {
"rows": [{
"name" : PropertyName
}],
"dataShape": {
"fieldDefinitions":{
"name":{
"name" : "name",
"aspects" :{},
"description": "",
"baseType":"STRING",
"ordinal": 1
},
"description": {
"name" : "description",
"aspects" :{},
"description": "",
"baseType":"STRING",
"ordinal": 2
}
}
}
} /* INFOTABLE */,
maxItems: undefined /* NUMBER */,
tags: undefined /* TAGS */,
nameMask: undefined /* STRING */,
query: query /* QUERY */,
maxDataItems: 500000 /* NUMBER */,
startDate: StartDate /* DATETIME */,
endDate: EndDate /* DATETIME */,
oldestFirst: true /* BOOLEAN */,
dataQuery: undefined /* QUERY */
});

var params = {
t: result2 /* INFOTABLE */,
nameColumn: "name" /* STRING */,
valueColumn: "PumpRunSignal" /* STRING */,
timestampColumn: "timestamp" /* STRING */
};

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

If I understood your implemented code then 'PumpName' variable in your service holds the name of the Pump thing for which you actually want to query the data, Is my understanding correct??

If yes, then you can just invoke the service 'QueryNamedPropertyHistory' for that pump thing

ex.

if(Things[PumpName])  //Check if the Pump thing actually exists
{
  var result = Things[PumpName].QueryNamedPropertyHistory(params <pass your params>);
}

I think it would be cleaner solution and much easy to maintain.

However I might be missing to understand use case and the need to call 'QueryImplementingThingsWithNamedPropertyHistory', if you can elaborate on it.

 

Regards

Aditya Mittal

View solution in original post

2 REPLIES 2

Hi,

If I understood your implemented code then 'PumpName' variable in your service holds the name of the Pump thing for which you actually want to query the data, Is my understanding correct??

If yes, then you can just invoke the service 'QueryNamedPropertyHistory' for that pump thing

ex.

if(Things[PumpName])  //Check if the Pump thing actually exists
{
  var result = Things[PumpName].QueryNamedPropertyHistory(params <pass your params>);
}

I think it would be cleaner solution and much easy to maintain.

However I might be missing to understand use case and the need to call 'QueryImplementingThingsWithNamedPropertyHistory', if you can elaborate on it.

 

Regards

Aditya Mittal

slangley
23-Emerald II
(To:SP_9715784)

Hi @SP_9715784.

 

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

Top Tags