Location mode APIs keep returning errors in smart app

Has anyone written a smart app that uses the ModeSetting/subscribeToModeChange APIs?

I’m working on a smart app that should start execution when a location mode change is detected but I keep running into issues when using the Mode related APIs. I’ve tried several times:

  1. Creating a smart app with a page section that defines a modeSetting. When I try and add my smart app as a new routine, it will fail to render with an error and my cloud watch logs show a response like this:
debug: RESPONSE: {
"statusCode": 500,
"message": "Server error: 'Error: Request failed with status code 403'"
}
  1. I’ve tried bypassing the modeSetting completely and setting up a mode event handler using await context.api.subscriptions.subscribeToModeChange('modeChangeHandler') within the updated phase of the lifecycle. I see the updated handler get called but in my cloud watch logs, I again see the status code 500 failure along with the 403 forbidden response as per #1 above.

  2. Tried to just query for the current location mode within the updated phase by calling await context.api.modes.getCurrent() directly. Again, I see the updated phase get triggered when my smart app is added in the smartthings app but the same status code 500/403 forbidding response is found in my cloud logs right after my log traces that show the updated phase being run.

  3. Explicitly adding

.permissions(['r:locations:*'])
.appId('XXXXXXXX-XXXX-XXXX-XXXXX-XXXXXXXXXXXX')

when creating the SmartApp(). I’ve tried adding all the scopes available to the permissions array also to no avail. When adding the permissions explicitly like this, the smart app fails to render right away without any errors in my logs. The initialization phase succeeds with a 200 and the response payload has the permissions I’ve listed as part of the response.

It seems like there’s some scope permissions missing that allows me to make these mode related calls but in my connector setup in the developer workspace for this smart app, I’ve permitted all the scopes that are listed there already and tried explicitly setting them in code (see #4 above). I’m not sure what I’m missing to make this work and I’ve not seen any samples yet that relate to location mode settings and/or mode change event subscriptions.

Using other APIs like subscribing to device events or using deviceSetting in smart app page sections work fine. It’s specifically the mode related APIs that I’m struggling with. Has anyone tried using the location mode APIs yet and have gotten them to work or can point me towards a working example?

I’m writing this as an AWS lambda function using the node.js SDK.

It does rather look like you should just need r:locations:* selected in the Developer Workspace and explicitly requested in the app (it has to be in both and it has to be written the same in both - the Developer Workspace end is like a whitelisting, the app end is the actual selection). It sounds like you’ve tried that though.