How do I manage Alexa smartplugs with Smart Home Skills?

96 views Asked by At

The goal is to create a skill that creates routines based on a variety of conditions, for example, the weather. I used to do it with https://alexa.amazon.com/ and this library, but it is now outdated and I turned to skills.

I've done and understood the initial steps. I've created a Smart Home Skill, set up a lambda function, authorization, etc. I had trouble with it not sending a discovery request due to an oversight setting up the regions, but it is fixed now.

Is there a way for the discovery request to see all the devices connected to this Amazon account and recognize the plugs?

The payload I have now in the discovery response is very device-specific, with the friendly name, the serial number, and the software version I have in the app:

var payload = {
        "endpoints":
            [
                {
                    "endpointId": "endpoint-sp-01",
                    "manufacturerName": "Amazon",
                    "friendlyName": "First Plug",
                    "description": "Amazon Smart Plug",
                    "displayCategories": ["SMARTPLUG"],
                    "additionalAttributes": {
                        "manufacturer": "Amazon",
                        "serialNumber": "xxxxxx",
                        "softwareVersion": "300000003"
                    },
                    "cookie": {},
                    "capabilities":
                    [
                        {
                            "interface": "Alexa.PowerController",
                            "version": "3",
                            "type": "AlexaInterface",
                            "properties": {
                                "supported": [{
                                    "name": "powerState"
                                }],
                                 "retrievable": true
                            }
                        },
                        {
                        "type": "AlexaInterface",
                        "interface": "Alexa.EndpointHealth",
                        "version": "3.2",
                        "properties": {
                            "supported": [{
                                "name": "connectivity"
                            }],
                            "retrievable": true
                        }
                    },
                    {
                        "type": "AlexaInterface",
                        "interface": "Alexa",
                        "version": "3"
                    }
                    ]
                }
            ]
    };

The code is based on this example in node.js.

How do I modify this so the skill discovers all the Amazon plugs connected to my account? It doesn't even show this specific plug so am I completely wrong? Am I missing some mandatory fields?

1

There are 1 answers

0
randyth On

As far as I know, you cannot control another company's smart home devices from your own personal, custom skill. In other words, only Amazon can develop skills that control their smart plugs.

You could, however, create an Alexa Routine that controls an Amazon smart plug. The trick here is finding the right trigger for what you want to do. For example, I do not believe Amazon has any built-in weather triggers for Alexa (see this thread for more information on weather triggers: https://www.amazonforum.com/s/question/0D54P00006zSyJESA0/weather-trigger-for-routines).