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 */
};
Solved! Go to Solution.
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
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
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