Grovestreams control of Imp

Anyone done any on/off control or variable passing to Imp from Grovestreams?
Suggestions or examples sought…

@hvacspei - Your time has come :slight_smile:

Ok, I now have found the way to pass a variable to the Agent, it appears there as {“chktime”:1200}

The stream ID is chktime, the variable passed is 4 bytes with 4 integers, containing the time as hhmm at which I wish to perform some daily routine on the Imp.

I’m not sure what form this is in or how to decode it though…

I have tried http.jsondecode() and get a result that is (table : 0x7f04f4033ee0) , but the digits change with each response…is it 64 bit encoded? Tried to decode from that too, but got nothing as a result.

Any suggestions?


The (table: 0xstuff) is actually just a pointer to the decoded object.

You need to access fields in the table, instead of the table itself - it looks like you want the chktime field, so your code will look something like this:

// decode the data: jsonString should be the variable with the json string in it local data = http.jsondecode(jsonString); // check if the decoded data has a field called chktime: if ("chktime" in data) { // do something with data.chktime: server.log(data.chktime); }

That makes sense…I’ll give it a whirl tomorrow.
Many thanks,

@beardedinventor…you kill me! :)) Seriously, I’m just a satisfied user!

Actually, I’ve not driven device actions via GroveStreams, although I’m confident it can be done via their action “HTTP Call”.

@pinsull, please post any more questions. I try to look at the forum rather frequently and I have a pretty good relationship with the GroveStreams folks should we need their guidance.

I have used HTTP commands from a web browser to transfer values to Imp, but I am not familiar with HTTP call from Grovestreams interface.

The Widget aspect of Grovestreams affords a convenient, unified way of setting any parameters at the Imp, by embedding them in the normal return response that happens as a result of data being conveyed to Grovestreams.

As per beardedinventor advice above, I now have that method working for me.

The thing is, that if there are many parameters…say several numeric, plus a few strings, I’m not sure what limitations there may be looming.

Also, this data is being returned with every Put response I believe, so it is being sent unneccesssarily often really.

This is still part of the same transaction though, so perhaps there is no penalty other than excess use of internet data…?

If you go into the Component Studio and into Event Action Packages, you will see that you can have actions such as: Grovestreams Notifications, send email, send SMS and HTTP Call. In the HTTP Call action, you can set it to GET or PUT or POST or DELETE and can pass headers along with parameters in the URL, if desired.

What you might do is have the Action Package associated with an event that you trigger when a value is received for a stream and then use the Stream Feed Form to post that data to GroveStreams. I’m not sure if this addresses your need, but it sounds like it might.

Don’t hesitate to post a question on the GroveStreams forum. They’re very good at timely and knowledgeable responses to inquiries.