@iceled I’m the author of the library. Thanks for pointing out that the error handling wasn’t sufficient. I’ll make notes to try and get this updated in a future version.
Since this library is making HTTPS calls, we do limit users to 5 requests/sec. To be efficient with Internet traffic, you should batch calls and use the sendEvents() function of the library. sendEvent() is meant for low frequency data like sending once every 300+ms.
The “value” property/parameter of both sendEvent and sendEvents functions currently accept simple data types as values i.e. string, number, bool.
So, you would send data like this (using your example):
function testis(){ // note, sending a batch of events like this with multiple values for the same keys // may ultimately not make sense without overriding when the event actually happened // i.e. providing an epoch timestamp. is.sendEvents([ {"key": "p1", "value": 1},{"key": "p2", "value": 5}, {"key": "p1", "value": 2},{"key": "p2", "value": 6}, {"key": "p1", "value": 3},{"key": "p2", "value": 7}, {"key": "p1", "value": 4},{"key": "p2", "value": 8} ], function(err, data) { if (err != null) server.error("Error: " + err); }); }
Note, the sendEvents function takes a single dimension array of objects. These objects need at least a “key” and a “value” property and can optionally include an “epoch” to override the timestamp of the event. Here is some more information on throttling and bandwidth use as well as docs on how the Initial State API should be consumed.
This is a first pass at an Electric Imp library, so feedback is welcome! Additionally, the library is open source and improvements/enhancements are very welcome through github pull requests. Likewise, if you have any feature requests for the library or for Initial State, feel free to file them at support.initialstate.com
Cheers! Hope this helps.