GroveStreams

Attempting to use Alexa to retrieve GS data481

fixingthingsguy private msg quote post Address this user
Leave it to me try the unknowable, but I'm there in the world of AWS Lambdas,skills, etc.
So at first I'm trying to request data using Alexa(not there yet) from GS using :
http://grovestreams.com/api/27257264/13628632%20smoke/api_key=xxxxxxxxxxxxxxxxx/feed?s3
In order to test before I wade into the Alexa world, I'm inserting above in a browser and I'm receiving this message:
*******
Not Found
The server has not found anything matching the request URI
You can get technical details here.
Please continue your visit at our home page.
*******
The compid is right,the compname is right, the syntax seems to be right, the api_key is "my" key. s3 is the stream ID.

Any debugging suggestions appreciated. Please don't ask me yet how to get the skills working, for me the process looks byzantine, but there are a few examples out there I can work with to hack my request into place.
Anyway, thanks for any suggestions.
Post 1 IP   flag post
MikeMills private msg quote post Address this user
To get the last value of a stream the URL needs to look like this:
http://grovestreams.com/api/comp/{compId}/stream/{streamId}/last_value?api_key=xxxxxxxxxxxxxxxxx

Replace {compId} with the ID of the component.
Replace {streamID} with the ID of the stream.

Right, the browser is a good place to test a GET.
Post 2 IP   flag post
MikeMills private msg quote post Address this user
I have an Alexa too, so it will be cool if you can post what it took to get it to work.
Post 3 IP   flag post
fixingthingsguy private msg quote post Address this user
Mike-Thank you. It works as you pointed out.
Yes, I certainly will update you on how the skill generation works.
I'll send you the link by email as I lost it amidst a bunch of searches but my hack will try to insert our GET into that code in the AWS Lambda software. I'm not a major coder so be aware what I'm saying may not be all thought out.
Post 4 IP   flag post
fixingthingsguy private msg quote post Address this user
Here's the link.
https://internetofhomethings.com/homethings/?p=1883

"Alexa, Ask ESP8266 for Temperature Readings"

Of course ESP8266 really hasn't anything to do with it, its basically a skill to read a value from a database on the internet that is custom to some app, in this case an ESP8266.
The skill does not interact with the ESP8266.
There are other apps that do that by emulating a Belkin plug, but its very very limited to on and off of a led, bulb or whatever.
Post 5 IP   flag post
fixingthingsguy private msg quote post Address this user
Here's a much easier to understand link that I was able to use
to develop an Alexa skill that reads last temperature value from my home.
Just follow the outline.
http://analyticphysics.com/Diversions/An%20Alexa%20Skills%20Kit%20(ASK)%20JavaScript%20Cookbook.htm

Simply put you need first set up accounts on https://aws.amazon.com/
and https://developer.amazon.com/.
(One of these requires a credit card, but appears no charge for low usage-tbd)
Then you develop a node.js module for insertion into Lambda on the AWS site. THis is the software that will extract whatever data you are trying to get and present it on a format that Alexa can understand.(requires the use of GET as shown in GS API section,to pull whatever stream data you want-See above helpful note from Mike Mills. Best to try that all this works on node.js before taking it over to the lambda)
The developer.amazon.com site is for writing the Alexa skills. I used the skills in the link.

Find your skill under "your skills" in the alexa webpage (amazon.com/alexa)

Kind of sketchy, but it all worked out for me.
Post 6 IP   flag post
fixingthingsguy private msg quote post Address this user
So here is a little more meaty stuff to guide you. Best to have the link I sent (analyticalphysics.com).
I entered this skill info as is:
Extracted....
Every skill requires an intent schema with at least one defined intent. The following minimal schema is sufficient for a functional skill:
{ "intents": [ { "intent": "Help", "slots": [] } ] }
Apparently intents need not include the word “intent” in their names. This minimal schema can be accompanied by the minimal sample utterance
Help help (you can change "help" to whatever you want, it doesn't matter because the skill does not require a parameter. (You might chose to do so sometime, but not this example)
and Alexa will respond appropriately when the skill is launched.
End Extract-------

There are a few other things to enter such as name, etc. and 5 different tabs to enter, but only 3 to get going.
You can research all that in the Alexa site https://developer.amazon.com/.

Next you go to the AWS lambda site and create a new lambda for yourself, give it a name etc. Ultimately this will need to be linked to the Alexa skill page on the Alexa site.
Here's the node.js I used

exports.handler = function( event, context ) {

var https = require( 'https' ); var str;
var text = 'Bix says your inside temp is:';
var url = 'https://grovestreams.com/api/comp/2126136/stream/s3/last_value?api_key=xxxxxxxxxxxxxxxx';

https.get( url, function( res ) {

res.on('data', function(d) {
str = JSON.parse(d);
process.stdout.write(d);
text+=str[0].data; //my json: {"time":9941xx,"data":76}
output(text,context);
});
res.on('end', function() { ;
});
res.on('error', function(e) {
context.fail("Got error: " + e.message);
});

});

};

function output( text, context ) {

var response = {
outputSpeech: {
type: "PlainText",
text: text
},
card: {
type: "Simple",
title: "Temp",
content: text
},
shouldEndSession: true
};

context.succeed( { response: response } );

}

The Lambda app needs to be saved, the link value needs to be physically transported to the Alexa site. Then you are ready to test. A testing facility is provided as well in this site.


Sorry, not a great writer, but read the link (analy..physics) and use the code above with your modification for Grove streams.

I'm not a high flying coder, but I will try and help if you have questions. I'm learning this as we go along.
Regards
Post 7 IP   flag post
2965 7 7
Log in or sign up to compose a reply.