I am designing a simple smart home device consisting of a wifi connected switch. I want to determine if that switch is open or closed. Currently, I used code to simulate a Belkin Wemo switch. It functions well mainly because Alexa will discover it and control it locally. It reports its state in JSON to an external website for which I wrote a custom skill and lambda function to read it upon voice request to Alexa echo. I want to do this properly using the smart home skill API.
After many days of looking at docs and sample code, I found bits and pieces of version 3 API sample code in python. I don't know python which makes it difficult to figure out how to do similar things in Node.js. The python example doesn't appear to use a device cloud service (an external website that communicates with the switch). So I may be missing a key piece of the "15-minute" tutorial.
I thought maybe the sample_async code might reside on the device cloud server but the anemic instructions did not say where the python code resides (lambda or device cloud). In either case I can't use it anyway.
The JSON code found here has some good hints but it appears that the device endpointId is known in handleDiscovery payload already. There are stubs to make calls to the device cloud but I don't get how lambda already knows the endpointId before device is discovered.
Sanity Check:, I'm thinking I have to build a web page that receives JSON requests from the Lambda skill initiated directives and responds with appropriate JSON responses. I have seen snippets of JSON object using payload version 3. This is something I can do. What I'm completely missing is what the process is to register a device with the device cloud. Where is this documented? Each device has a unique id so there can be more than one of these devices.
For example, how does device discovery work when the lambda function makes that request and the device is not known to the web server yet? What is the process of registering the device to the web server? Should the device auto register when first powered up? Should it check the web service to see if it has previously registered if it restarts?
If there is a complete end to end example of making a hardware device Alexa smart home compatible, where do I find it? If it doesn't exist, can someone refer me to relevant examples? Any recommendations on how to proceed are welcome.
If this is something better handled by amazon cloud service please direct me on how to do that.