Duplicate faulty SmartApps created whilst developing

Hi there, first time SmartApp developer coming from the Groovy IDE ecosystem and I’m stuck at the first hurdle trying to develop a SmartApp.

I’ve created a test SmartApp in the new developer portal and deployed to test, but this results in 2 SmartApps of the same name appearing in my Smartthings App - one with my app’s description and one without. One of these appears to get created when I register the lambda, and the other gets created when I “deploy to test”

I’m hosting the app code in AWS lambda, but neither SmartApp entries invoke it. They both give me separate error messages (see screenshots)

I’ve given Smartthings permission to invoke my lambda, and there’s nothing useful coming out of the live logging output either.

Can someone point out what I’m doing wrong please?

Many Thanks,
Ben

Tagging @nayelyz

1 Like

Hi, @foyst!
The duplicated entries are an issue in iOS. If I recall correctly, the one that should work correctly is the one without description (basically, the one that doesn’t give you an instant network error).
About a Lambda SmartApp, I suggest you check the points I mentioned on this post:

Thanks for the tag, @jkp!

1 Like

@jkp thanks for the tag and @nayelyz for such a quick response :slightly_smiling_face:

I didn’t know about the iOS issue so thanks for clearing that up for me!

I’ve gone through your points and my lambda appears to be configured correctly. I’ve even tried using the GitHub - SmartThingsCommunity/smartapp-example-no-devices-nodejs-lambda: Give Lambda SmartApps a try without any physical devices. example and it still gives me the “Something went wrong, Please try to install the SmartApp again” error.

I’ve granted permission for both 148790070172 and 906037444270 to invoke my lambda - my understanding is only 906037444270 is needed as I’m writing a SmartApp without Smartthings Schema, but added them both just to rule that out.

I do see the following lifecycle event in live logging when doing the above if it helps:

{
    "type": "INSTALLED_APP_LIFECYCLE_EVENT",
    "data": "{\"eventTime\":1664531977075,\"eventType\":\"INSTALLED_APP_LIFECYCLE_EVENT\",\"installedAppLifecycleEvent\":{\"locationId\":\"03dd9e7c-5015-45c1-931a-0217a990c1da\",\"installedAppId\":\"be635f91-d76e-4444-8918-902633d54312\",\"appId\":\"7c8d8533-aec1-4338-8822-f19d923fee6f\",\"lifecycle\":\"CREATE\",\"create\":{}}}",
    "lastEventId": "",
    "origin": "https://spigot-regional-euwest1.api.smartthings.com"
}

Also, after seeing that error the SmartApp does appear under my list of installed apps with “Setup not complete” under it. Clicking the app there results in the same error being thrown again.

What else could be the problem?

Thanks

Yes, this is the only one.
When you uploaded the sample you shared, did you configure any settings? This sample has none so it won’t show a page for you to enter something. Once it gets installed it prints “Hello installed!” in the logs but nothing else.

This is the empty section:

On this repo, there are samples for every type of setting and you can see how they are imported here but they come from the directory pages like this index-page.js file.

The structure of the settings is the same for a WebHook and a Lambda SmartApp. Here’s another sample of the structure:

This means you should still use the sample of smartapp-example-no-devices but add at least one “setting” on that page to see the configuration in the app.

Hi @nayelyz, thanks for your continued support on this.

I tried adding the config you suggested, but it’s still erroring out.

It doesn’t look like it’s getting as far as the lambda being triggered - AWS is registering no invocations of my lambda, there’s no logs for it in AWS or the live logging console in Smartthings.

I was running in us-east-1 and saw your post about deploying the lambda in the co-located region in AWS

I queried the Smartthings location API which has my countryCode as GBR and I redeployed to eu-west-1, but unfortunately still get the “Something went wrong” error.

When do you get this error? For example, when the app tries to open its settings page or when clicking on install?
Can you share your SmartApp’s definition, please?

I’ve created a recording of the error, hopefully that shows what you’re asking for.

smartapp-error

Not sure what you mean by definition, but this is my lambda code if that’s what you mean (I’ve moved away from the smartapp-example-no-devices template):

import { SmartApp } from '@smartthings/smartapp'

const smartApp = new SmartApp()
    .enableEventLogging(2)
    .appId('7c8d8533-aec1-4338-8822-f19d923fee6f')
    .permissions(['r:devices:*'])
    .page('mainPage', (_, page) => {

        page.section('Text', section => {

            section
                .paragraphSetting('info').text("This is some test text")
        })
    })
    .installed(async context => {
        console.log("Hello installed!")
    })

export default smartApp

ok, using this exact configuration is when I get the error, but I copied the SmartApp definition and it isn’t causing the error, so, if you’re modifying the sample of no-devices-nodejs-lambda-dev-smartapp, I think the export/import could be affecting the execution.

Using the config below works for me:

const { SmartApp } = require('@smartthings/smartapp')

module.exports = new SmartApp()
.enableEventLogging(2)
.appId('7c8d8533-aec1-4338-8822-f19d923fee6f')
.permissions(['r:devices:*'])
.page('mainPage', (_, page) => {

    page.section('Text', section => {

        section
            .paragraphSetting('info').text("This is some test text")
    })
})
.installed(async context => {
    console.log("Hello installed!")
})

And that did the trick! :slight_smile:

I was able to get it working using your suggestion above, and from there I figured out what the problem was.

I’m writing mine in Typescript (hence why the import/export looked suspicious) and an innocuous bit of syntax was completely breaking the lambda, causing it to not print out any logs either which is why I thought the lambda wasn’t being called at all.

Thanks so much for helping me with this and for your patience @nayelyz, it’s really appreciated!

1 Like

I’m happy to help, don’t hesitate to reach out again if you have more questions :smiley:

1 Like