1

After days of searching I decided to ask here for some help. I want to publish an Alexa Skill which can controll some electric motors.

Current state:
- 1 User
- 1 Alexa
- 1 Local Network
- 1 Raspberry Pi
If the user invokes the skill which sends a json-request to a Lambda function. This functions sends a http-request (with a DDNS I "know" the IP address of the router which forwards the reqest to the Raspberry Pi) to the Raspberry Pi (on which a local webserver is running). This local webserver sends now instructions over the serial interface to the electric motors.

My Problem:
If I add a 2nd or 3rd or 1000th local network (see image), i cant differ anymore between these networks in the Lambda function. How do I know which User belongs to which Raspberry Pi?

I'm about to implement openHAB, AWS IoT or Pubnub, so I dont have to worry about the communication between a specific Raspberry Pi and the Lambda Function. How ever after this implementaion the Lambda function still doesn't know which Raspberry Pi the User means?!

Ah and the User can only control his own Raspberry Pi which is in the same local network.

Basic Architecture

Markus
  • 98
  • 1
  • 7

1 Answers1

0

You can specify a unique user ID in the JSON request. Inside your Lambda Function, you can PubNub publish on a channel that is specific to an individual Raspberry Pi. Each of your Pis can PubNub Subscribe on their individual channel.

Get your forever free API keys here

enter image description here

PubNub Publish without an SDK:

GET request to: 
http://pubsub.pubnub.com/publish/your_publish_key/your_subscribe_key/0/channel_name/0/{"your_json":"data_here"}
Adam
  • 659
  • 4
  • 13
  • so if I understand this right, I have to save or link the `amzn1.ask.account.[unique-value-here]` - user ID to a specific Raspberry Pi (-channel)? Because otherwise I still don't know on which channel I should publish. – Markus Jun 23 '18 at 15:35
  • Yes you can use a user ID that is specific to each Raspberry PI for the PubNub Channel. Just make sure that the string you use for the channel is 92 characters or fewer in length. – Adam Jun 24 '18 at 15:57