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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

AddStreamEntries error

SB_9732186
12-Amethyst

AddStreamEntries error

Hi all,

 

Getting error while executing AddStreamEntries service: 

JavaException: java.lang.Exception: Invalid number of values provided to AddStreamEntry

 

 

 

let newEntry = {
		sourceType: undefined, // STRING
		values: entries, // INFOTABLE
		location: undefined, // LOCATION
		source: undefined, // STRING
		tags: undefined, // TAGS
		timestamp: new Date() // DATETIME
	};
	// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(StreamEntryWithValues)
	let obj = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
		infoTableName: "InfoTable",
		dataShapeName: "StreamEntryWithValues"
	});
	obj.AddRow(newEntry);

	me.AddStreamEntries({
		values: obj /* INFOTABLE {"dataShape":"StreamEntryWithValues"} */
	});

 

 

 

Thanks,

Sujith

ACCEPTED SOLUTION

Accepted Solutions

use below service

 

Things["TestStream"].AddStreamEntries({
	values: dataset/* INFOTABLE */
});

 

"dataset" is the nested infotable as below, which uses "StreamEntryWithValues" datashape.

Sathishkumar_C_0-1663316212953.png

In "StreamEntryWithValues" datashape, there is one infotable field called "values

In "values" infotable, you will have your own data set.

Each row consider as one entry in stream.

 

Hope it helps

View solution in original post

6 REPLIES 6

//TestValuestream is the value stream name

let values = Things["TestValuestream"].CreateValues();
values.x = new Date();  //your datashape fields
values.y = 10;  //your datashape fields
let params = {
    tags: undefined,
    timestamp: new Date(),
    source: me.name,
    values: values,
    location: undefined
};
Things["TestValuestream"].AddStreamEntry(params);

result = values;

 

try above code

Hi @Sathishkumar_C ,

 

I want to add multiple entries to the Stream at once, not only one entry.

 

Thanks,

Sujith

use below service

 

Things["TestStream"].AddStreamEntries({
	values: dataset/* INFOTABLE */
});

 

"dataset" is the nested infotable as below, which uses "StreamEntryWithValues" datashape.

Sathishkumar_C_0-1663316212953.png

In "StreamEntryWithValues" datashape, there is one infotable field called "values

In "values" infotable, you will have your own data set.

Each row consider as one entry in stream.

 

Hope it helps

Hi @Sathishkumar_C 

 

I tried using "AddStreamEntries" service but I get this error:

 

 Error executing service getPwrSupplyErrorReport. Message :: Wrapped java.lang.NullPointerException - See Script Error Log for more details.

 

How can I fix this?

 

Many thanks

it might be because of passing null values to the integer/number fields. Please share code here, if possible.

yes below is my code:

 

//creating an infotable

let Log = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "DataShape"
});

 

//Defining date variable

var currentDate;

 

//assigning valueList variable to my infoTable property that contains values (current it only has one row)

var valuesList = Things["TestThing1"].infoTableThingProperty;

 

//loop through the infotable above
for(var i=0; i<valuesList.length; i++){

// new object 
newEntry = {
duration:valuesList[i].duration,
source: valuesList[i].Source,
Name: valuesList[i].Name,
Type: valuesList[i].Type,
StartTime: valuesList[i].StartTime,
EndTime: valuesList[i].faultEndTime,
Voltage: valuesList[i].Voltage,
Text: valuesList[i].Text

};

//adding my object values to the infotable
Log.AddRow(newEntry);
}

 

//adding my infotable to the stream 

var newLog = Things["SinkWorx.PwrSupplyError_Stream"].AddStreamEntries({
values: Log /* INFOTABLE {"dataShape":"StreamEntryWithValues"} */
});

 

//output result

let result = Log;

 

 

 

Announcements


Top Tags