Simple SmartApp Tutorial (SmartApp SDK)

Thanks for your swift answer, I found it as you explained.

1 Like

I have nodeJS SmartApps I’m running on a Raspberry Pi using ngrok. Because I have the free tier version of ngrok, I get only one URL to use, so I have to use the same one for multiple SmartApps I may want to be running. So far this hasn’t been a problem, as I can simply key off of the appId when a POST message is received to direct the message to the right SmartApp instance.

However, I have run up against an issue with the language support: I have these lines in my SmartApp instantiation for each of two SmartApps:

.configure 18n({prefix: “app1_”})

.configureI18n({prefix: “app2_”})

This allows me (presumably) to keep the en.json files separate for each SmartApp, at least that was the intent…

The problem is that this doesn’t work. It seems that the SDK is not keeping the two I18n instances separate. Only the .configureI18n for the second SmartApp that is loaded (via nodeJS require) seems to honored. The first SmartApp to load is missing all its text in the mobile app; the second one is fine. If I copy all of the app1’s json into app2’s json file (app2_en.json), then they both work ok. This leads me to believe that invoking .configureI18n uniquely for different SmartApps doesn’t work properly in the SDK.

Is there some other way I can accomplish this? I don’t see any other way of providing a specific file name to .configureI18n, but if the SDK isn’t keeping them separate across SmartApps, then it may be impossible without a fix to the SDK.

Hi, Todd!
Please, allow me to check with the engineering team and I’ll get back to you as soon as I can.
Update:
@TAustin, the workaround you’re using is the best bet. The team mentioned it is due to the way the i18n package is handled by the SDK.
So, please open an “issue” directly in the Github repo so they can analyze it further and see if it can be supported.

2 Likes

Was there ever example made that showed the sdk running client side like you mentioned?

I have been trying to get it working, but im quite new to running modules client side.

Thanks

Hi, @lmullineux!
Can you provide more details about how you’re trying to do it and why it isn’t successful, please?
The case mentioned by Jody was using the Core SDK, which the SmartApp SDK is based on and there’s a sample of its usage on this repo:

Newbie issue
I followed the instructions on the video (noted some small UI changes).

  1. It seems like the test script has been changed since because the page url does not show the port 3000 after the url (code is a little different to what is in the video
  2. I couldnt pass the app registration if it was not for post 25
  3. I am not sure if I absolutely have to but I put the android smartthings app in developer mode. I fumble my way through it but it would be great if those instructions were posted

Now the app showed app for me on my smartthigns app (woohooo!!!) but when I click on it I get the spinning animation and a few seconds later “We’re having trouble connecting. Check your network connection and try again”. Many times

Any advice?

Hi, @Gabriel_Arce!
Thank you for your comments.

Just as a reference, the tool Glitch changed the way we need to get the link to call the app, that’s not in our control.

The common issue that causes this message is that you don’t have the same scopes in your SmartApp and in the Developer Workspace.
Did you only change the page section of the app? In the tutorial, he only selects r:devices:* and x:devices:* but if you defined another one in the app, you’ll get the error, I mean something like:

app.enableEventLogging(2)
.appId("...")
.configureI18n() // Language file in ./locales folder
.permissions([
    "r:locations:*",
    "r:devices:*",
    "x:devices:*"
])
//...

Thanks for your help.

  1. Still not clear what should go on the hosting section of Developer Workspace? include 3000 or not at end of url. when not including 3000 fails very quickly so I pressume I need 3000
  2. The video and sample code at Glitch posted did not have that permissions section at all. I added it (but not sure if that was really needed)?
  3. The video show enabling only r:devices and x: devices on Developer Workspace. I updated so it includes r: locations

Still no luck but I am not sure I am following the right process to update the app
ST app: Delete Smart App Automation section (remains under discover)
Glitch: Update code - no need to deploy or anything, live updates
SDW: On Deploy to test click unlist from test. Make changes to automation section if needed. Click re-verify if needed
ST app: Try to find the App in Discover and click to install. Sometimes errors and sometimes comes back without error. Sometimes shows an App under “SmartApps”. Always produce error mentioned.

I do see some traffic on SDW Live logging which I obtained.
Anything I should look on the logs? Or maybe another tutorial to follow?

UPDATE: I removed the additional permission code I added based on your comment on a different thread here @nayelyz - also 1) just in case tried just on mobile network / disable wifi to remove my router from the equation 2) Issue is same on Pixel 4a and Samsung Tab S6 lite

No, it was an example just to show what could cause an issue, sorry for the confusion.
Ok, so the issue is still the URL, I understood you were all set in that part.
In this new version of Glitch, we need to:

  1. Select “Share” and copy the URL next to “Live site”

  2. Put this value in the Developer Workspace.

  3. You’ll get the confirmation URL, which you need to paste in a new browser tab and hit enter to verify it.

Note: Once the URL is verified, you’ll be able to open the SmartApp. Even if the URL is saved, it won’t let you open the app.

About your steps:

This is only to define it is no longer installed. It will remain in “discover” if it’s deployed to test.

Correct

This is not necessary after any change you make. The app can remain deployed to test in the Developer Workspace and its URL, scopes, etc. can change.

I’ll mention this to the team to see if they can put a note in the post. Thank you for sharing your experience :smiley:

Thanks, this is ok

Thanks. So in Samsung Developer Workspace for hosting there is no port - just the url
It works now. Thanks!
Really, tutorial is very straighforward once the url (error in the video) is clarified and the registration better explained. I think it is easy to get pass the UX differences as long as the rest is good

Glitch: This is outside your control but I have tried to “remix” a project and waited for sometimes 20 minutes (at which point I cancelled so not sure if it would have been successful). Sometimes it took as long to open another person project. Loging out and seem to be faster. They were having a bad day :face_with_open_eyes_and_hand_over_mouth:?

UPDATE - Small observation, I think there are issues using Glitch on Brave browser (similar to chrome). Also on the smartthings app, I was getting a blank screen instead of the screen to grant access to the app. I was able to resolve this by changing the default browser on my smartphone to Chrome.

In this case yes. It mostly depends on the host you’re using but consider that in Glitch, the Live site is the “public URL” they provide for external access and the port that is used as a listener in the project is still there but it’s accessed internally.

I experienced something similar, but I thought it was because I wasn’t logged in. I’m not sure. It didn’t happen in the past.

Hello,
I’m following this tutorial, but I can’t find the option of “Automation for the SmartThings App” at the SmartThings Developers workspace, do you know what happened? It only shows the option of “Device Integration”.
Also I tried to create a SmartApp from the API Rules but didn’t work either.

2 Likes

I have the same problem. The “Automation for the SmartThings App” is gone.
Before, I can create an “Automation for the SmartThings App” at this link Developer Workspace
But it doesn’t work anymore.
There’re 4 types of projects and I think CPT-PARTER is the one like “Automation for the SmartThings App”. I followed the documentation here for SmartApps Get Started with Cloud Connected Devices | SmartThings Developers, but in step 4 my server redirect the link to https://c2c-ap.smartthings.com/oauth/callback?response_type=code&state=eyJhbGciOiJIUzM4NCJ9.MzYwNDEwYmMtOWU2ZC00NmYxLTkzNzctMjQ5MjQ0ODU2ZTlkOnZpcGVyXzVmMTEyNzIwLTY5M2ItMTFlZC1iNTY2LWM5ZDMwMWJhOWU5MDoxNjY5MDExODQzMTE2OjNjZGYwZmQyLTRkMWYtNDMzZi1hMGQ0LTA0YTcxZTQxN2JlMjplbjo.mxwtapxHTwA4M0hdn6JIaAJ3Gb57uC1ultEj59OoAudr9yF8cfSA2aK-tMykIn9D, and in step 5, it always told me “Somethins went wrong… Request Code: 0WIFZF”. Different request code every time, but always wrong.
Can anyone tell me what’s the right redirection and is there any sample code I can follow?
It looks like this is a big change to people who use Automation connector. Anyone has any comments?
Thanks
@nayelyz @JDRoberts

2 Likes

I’m sorry, I don’t know anything about this part of the architecture. Hopefully others will. :thinking:

I got to 6 minutes and 44 seconds into this tutorial and can’t add smartapp to my iphone or samsung smartthings app

Hi, @wptracy!
Sorry about that, here are the instructions to test a SmartApp: Test Your Connected Service | Developer Documentation | SmartThings

Just copying them here:

1 Like

Thanks nayelyz.
I added the routine, but it doesn’t appear on the list of routines.
Is this not permanent?
How do I install a smartapp? IDE will be gone the end of this month.
I thought this might be the future soution.

If the SmartApp doesn’t appear in the options I mentioned before, it might be because it isn’t deployed to test. It must appear like this in the Developer Workspace:

oh, also, did you enable the developer mode? Here are the instructions: Test Your Device | Developer Documentation | SmartThings

4 posts were split to a new topic: Migrate Elder care app & Google sheets logger

6 posts were split to a new topic: [Endpoint SmartApp] Help executing commands based on subscriptions