Alexa skill + Smartthings

They are using a smart home skill not a custom skill (the one you’ve mentioned in your initial post)…

So by making a smart home skill, Alexa can automatically find devices from Smartthings?

Not only can find them and authorize them, but it doesn’t require an invocation phrase. (you don’t have to say alexa, tell smartthing to turn the light on. You just say, Alexa turn the light on)

1 Like

Of course, there is always a price to pay for “convenience”…A custom skill “is the most flexible kind of skill you can build” and “can handle any kind of request” with pretty much no restrictions on Amazon side. Often the restrictions are imposed by the developer.

1 Like

When making a smart home skill, how do I get the client ID and secret from Smartthings?

Via OAuth…

What I meant was how to get it from the Smartthings without making a Smartapp. This way I can have my Alexa skill direct me to the Smartthings authorization link when enabling the skill. How can I do that?

I am not actually clear on what you are looking for…the native integration will link up automatically as you are looking for…the disadvantage is it is not very configurable and you are limited by the limited functionality given to you by Alexa. The method Ask Alexa uses gives you complete control over your environment, but you must use a skill invocation name and you have a lot more manual pieces. Without another server in the middle to do some of the authentication tasks you are stuck with one or the other. I have a server in the middle I am working on to eliminate some of the limitations, but there will always be a manual aspect of the installation since it is so customized and can’t be published.

According to the example code below from https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/steps-to-create-a-smart-home-skill, how can I make the lambda function discover all devices available? Is there any simple way to discover devices without any specific details because all the code does is make a virtual device.

def lambda_handler(event, context):
    access_token = event['payload']['accessToken']

    if event['header']['namespace'] == 'Alexa.ConnectedHome.Discovery':
        return handleDiscovery(context, event)

    elif event['header']['namespace'] == 'Alexa.ConnectedHome.Control':
        return handleControl(context, event)

def handleDiscovery(context, event):
    payload = ''
    header = {
        "namespace": "Alexa.ConnectedHome.Discovery",
        "name": "DiscoverAppliancesResponse",
        "payloadVersion": "2"
        }

    if event['header']['name'] == 'DiscoverAppliancesRequest':
        payload = {
            "discoveredAppliances":[
                {
                    "applianceId":"device001",
                    "manufacturerName":"yourManufacturerName",
                    "modelName":"model 01",
                    "version":"your software version number here.",
                    "friendlyName":"Smart Home Virtual Device",
                    "friendlyDescription":"Virtual Device for the Sample Hello World Skill",
                    "isReachable":True,
                    "actions":[
                        "turnOn",
                        "turnOff"
                    ],
                    "additionalApplianceDetails":{
                        "extraDetail1":"optionalDetailForSkillAdapterToReferenceThisDevice",
                        "extraDetail2":"There can be multiple entries",
                        "extraDetail3":"but they should only be used for reference purposes.",
                        "extraDetail4":"This is not a suitable place to maintain current device state"
                    }
                }
            ]
        }
    return { 'header': header, 'payload': payload }

def handleControl(context, event):
    payload = ''
    device_id = event['payload']['appliance']['applianceId']
    message_id = event['header']['messageId']

    if event['header']['name'] == 'TurnOnRequest':
        payload = { }

    header = {
        "namespace":"Alexa.ConnectedHome.Control",
        "name":"TurnOnConfirmation",
        "payloadVersion":"2",
        "messageId": message_id
        }
    return { 'header': header, 'payload': payload } }

I think I see where you are going with this, and you are running into security issues with SmartThings. First, you can not have an interface between SmartThings and Amazon without a SmartApp…The SmartApp will allow you to create an OAuth that allows the path back into SmartThings. In addition, because of SmartThing’s security model, you must MANUALLY select the items that will be revealed via this OAuth. The native integration works this way as only devices you authorize can be seen by Alexa.

Hope that helps.

1 Like

I already made a smart app according to Smartthings’s authorization document and set up the example smart home lambda function from Amazon. So I made a smart home skill with the client ID and secret from the smart app and the other information from the authorization document. So when I click enable on the Alexa skill, it takes me to the authorization page to authorize my devices. However, when I tell the Alexa to discover devices, it only finds devices from the skill which is a virtual device. It doesn’t actually find real devices. So how could I make it find devices automatically? I’ve looked through some of the Amazon docs from https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/providing-scenes-in-a-smart-home-skill as well as from https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/smart-home-skill-api-reference#discoverappliancesrequest, but I don’t really understand how to make my skill discover devices connected to my Smart hub.

In your smart app, are you selecting the devices that you want Alexa to discover? You MUST manually select the devices and THEN have Alexa search for them.

It’s a security thing, no way around it.

Well I click enable on my Alexa skill and it brings me to this page to select my devices which I can then authorize.

I believe the problem is that the lambda function doesn’t find devices. So that’s what I believe I need help on.

Whats up guys, I’m trying to set up the askAlexa.I have a smart app installed. did all the Lambda install. On Amazon I could not get the custom slots to open as a copy and pasted the HTTPS:address from the app into the custom slots Types. Then it asked for valves, so I pasted the HTTPS: address there. now I’m getting this - Error: Catalog value https://graph-na02-useast1.api.smartthings.com:443/api/smartapps/installations/b38844fb-3376-4c78-b7a1-78c5d5e41c42/setup?access_token=d0253cea-1ac9-470d-8222-90d41e28de96 is greater than the maximum limit of 140

Any ides? Please keep in mind I’m not a code kind of guy…lol. I just like to try things that are way over my head.

Thanks Terry

I am the author of Ask Alexa. Regarding this statement:

I assume you are on the developer site. Did you happen to use the Beta Skill Builder? If so, I have found that Amazon is constantly changing that and I DON’T recommend it to anyone as it will be changing and make your apps stop working. And it makes a lot of assumptions about your skill and slows it down.

That being said, if you are NOT using that beta app, what error are you receiving? You should work in a ‘top down’ model with the Intents first, THEN the slots, then the utterances at the end.

PM me if you continue to have issues and I can walk you through them. The good news is that you are close!

1 Like

Thanks Michael, I will try again when I get home. From what I have seen of the Ask Alexa on youtube it is badass!!!
I didnt use the Beta Skill Builder. I have used the AWS only once. For Ask Google. The screen I get is different than the one in your post. But so was the Lanbda screen. I chalked it up to up grades sense your post. The Error I got is listed below. Thanks for the super fast reply!!!

Error: Catalog value https://graph-na02-useast1.api.smartthings.com:443/api/smartapps/installations/b38844fb-3376-4c78-b7a1-78c5d5e41c42/setup?access_token=d0253cea-1ac9-470d-8222-90d41e28de961 is greater than the maximum limit of 140

I would need a screenshot of that error to see where you are getting it. Amazon keeps changing their screens so I will spend some time this week updating the Wiki to reflect the new look.

PM me the information so you don’t have someone hack your account with what is shown on the screen.

Hello

could explain me the configuration in the Alexa Skill for OAuth (wiche URI,…)?
regards