question

mark4in avatar image
mark4in asked

Custom Echo device and Endpoint server (ASK + AVS) that can control hardware accessories (GPIO pins) on itself

I have achieved the following in last one year using AVS / ASK :

1. Create custom ASK and access them via a Raspberry (Alexa client) with Alexa Server running on EC2 i.e. replace my Echo device completely with my own Hardware (Raspberry Pi etc)

2. a) Run an OpenHab server along with a bridge (e.g. Alexa-HA github repo) so that instead of running a lambda function on Amazon servers, I use a local NodeJS server on my wifi network as the endpoint and thereby send appropriate commands to my OpenHAB server.

2. b) Control GPIO pins of a Raspberry pi (OpenHab server) in the above (2 a) scenario and use it to control connected hardware (motors, leds, IR sensors etc)

The tricky bit :

To achieve point 2 above - i.e. control what actions and code gets triggered on my custom hardware using the ASK intents/utterances, I needed to do some networking hacks :

1. Get a static IP (DDNS)

2. Map DDNS to my Router IP and then port forward custom service on my router to give access to OpenHAB (Alexa HTTPS endpoint)

Everything works perfect!

Here is my next challenge :

I am working on a product (using ASK/AVS to control this internet connected device and make it do stuff at the hardware level e.g. trigger some GPIO pins). The trick is, I cant expect my consumers fiddle with their router (as this device is on their wifi network) or do any of the geeky networking stuff to make this hardware work as I did. All they should do is connect it to their Wifi (or use a GSM SIM, not preferred), do some basic config like we do while setting up a new Echo device and rest works. Is it possible that I can create such a device (hardware+software) using Amazon Alexa technology stack?

In short, think of it as a pebble watch connected to the internet (via home Wifi or via a Mobile phone bluetooth -> Cellular internet or via a dedicated GSM SIM for itself) to which I can give a command and it can change, lets say, the brightness of the watch display.

P.S. : It has nothing to do with Pebble or smart watches so please don't get confused with the face value of the example above. Its all about dynamic network IP's, local alexa Endpoint, No port forwarding / configuring network.

alexa skills kitalexa voice servicealexaalexa smart homeecho
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Eric@Amazon avatar image
Eric@Amazon answered

Hi mark4in,

Rather than have a custom skill for each device, we would recommend having a single skill (running on EC2 or your own web server) that forwards the appropriate commands to your device. Your device can open a connection to your server and "register" so that your skill server knows who to send the commands to. If your device creates the connection to your server, you shouldn't have to deal with DNS / any other router issues.

Did that answer your question?

3 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mark4in avatar image mark4in commented ·

So you are saying that instead of having my endpoint (server) on my local Wifi network, I host that on EC2 itself. I got that point.

I need some more clarification and a bit hand holding on this statement though : "Your device can open a connection to your server and "register" so that your skill server knows who to send the commands to."

I am not lazy, just trying to get the logic behind the flow and how to implement this mechanism. Any examples, documentation, stack overflow pointers would do.

0 Likes 0 ·
mark4in avatar image mark4in commented ·

adding to my previous comment...by "register" you do not mean the alexa (java) client way where one authenticates to amazon server, gets a key on the popup, copies it to browser?

If yes, doesnt that key expire over a period of time? The device once sold to the customer wont have any mechanism to redo the client authentication token request step.

or may be my above understanding may be wrong/incomplete. Would appreciate your help.

0 Likes 0 ·
Eric@Amazon avatar image Eric@Amazon mark4in commented ·

Sorry, perhaps the word register is a poor choice. I meant that your device should open a connection to your own server so that the two know about each other. This step is entirely divorced from Alexa. The flow would be like this (for simplicity I'm assuming your server is running on EC2, but it can run anywhere):

User turns on device -> Device opens 2 connections - one to AVS, and one to your own personal server on EC2 -> Your personal server associates the device with the user and maintains the connection -> User initiates skill -> Skill intents get forwarded to your skill server -> your skill determines which device to forward the commands to based on which user is talking -> your skill server sends the commands to your device along the open connection.

Alternatively, you could look into doing this with AWS IoT:

https://developer.amazon.com/appsandservices/community/post/Tx3828JHC7O9GZ9/Using-Alexa-Skills-Kit-and-AWS-IoT-to-Voice-Control-Connected-Devices

0 Likes 0 ·