SmartThings Community

Having trouble building sample color weather app webhook automation


(Chetstone) #1

There is a tutorial example for an automation using the new API here.
I can get through it and see that smartthings is communicating with my webhook but it ultimately fails, probably because what I see on the form doesn’t match the instructions in one of the steps.

The instructions say:

  • For the Scope , click on Settings and select the following scopes:

    • r:devices:*
    • x:devices:*
    • r:schedules
    • w:schedules

Well, there is no Settings button, but I think they mean the Add button. When I click it I see a list of scopes which include r:devices.* and x:devices.* but r:schedules and w:schedules are not there.

If I just select the devices scopes and complete the rest of the instructions, when I try to install the automation, I can see the output of my webhook doing a configuration/installation step but the phone says Network/Server error and the webhook output includes the lines:

    permissions: 
      - r:schedules
      - w:schedules

which I’m guessing means that it’s complaining about no schedules scopes being provided by smartthings.
The full output is here.

$ npm start

> weather-color-light-SmartApp@1.0.0 start /Users/chet/prj/weather-color-light-smartapp-nodejs
> node server.js

Open: http://127.0.0.1:3005
CONFIGURATION lifecycle. Request body:
lifecycle:         CONFIGURATION
executionId:       4bcd7ecc-fa58-f182-bbdb-4d4ec80413e7
locale:            en
version:           0.1.0
client: 
  os:       android
  version:  1.7.20-25
  language: en
configurationData: 
  installedAppId: 12cb52be-a74c-44d0-88b6-db5472a1b221
  phase:          INITIALIZE
  pageId:         
  previousPageId: 
  config: 
settings: 
CONFIGURATION response:
configurationData: 
  initialize: 
    name:        Weather bulb color
    description: Bulb color by current temp
    id:          app
    permissions: 
      - r:schedules
      - w:schedules
    firstPageId: 1
PING lifecycle. Request body:
lifecycle:   PING
executionId: E5E199B1-6F81-4DC7-B8E7-4B55CB2C418C
locale:      en
version:     0.1.0
pingData: 
  challenge: 301be901-3c2c-4d86-b011-e83fc15bf814
settings: 
CONFIGURATION lifecycle. Request body:
lifecycle:         CONFIGURATION
executionId:       7a1786bf-27d0-bac4-247f-26d1d5209cb3
locale:            en
version:           0.1.0
client: 
  os:       android
  version:  1.7.20-25
  language: en
configurationData: 
  installedAppId: 12cb52be-a74c-44d0-88b6-db5472a1b221
  phase:          INITIALIZE
  pageId:         
  previousPageId: 
  config: 
settings: 
CONFIGURATION response:
configurationData: 
  initialize: 
    name:        Weather bulb color
    description: Bulb color by current temp
    id:          app
    permissions: 
      - r:schedules
      - w:schedules
    firstPageId: 1
CONFIGURATION lifecycle. Request body:
lifecycle:         CONFIGURATION
executionId:       4ac2485f-db65-f64c-e0bd-3afe19e21f13
locale:            en
version:           0.1.0
client: 
  os:       android
  version:  1.7.20-25
  language: en
configurationData: 
  installedAppId: 12cb52be-a74c-44d0-88b6-db5472a1b221
  phase:          INITIALIZE
  pageId:         
  previousPageId: 
  config: 
settings: 
CONFIGURATION response:
configurationData: 
  initialize: 
    name:        Weather bulb color
    description: Bulb color by current temp
    id:          app
    permissions: 
      - r:schedules
      - w:schedules
    firstPageId: 1
UNINSTALL lifecycle. Request body:
lifecycle:     UNINSTALL
executionId:   42093ba2-12fb-6ed8-b87a-d8ffda1ad20e
locale:        en
version:       0.1.0
uninstallData: 
  installedApp: 
    installedAppId: 12cb52be-a74c-44d0-88b6-db5472a1b221
    locationId:     b1c9b96b-1170-4278-adde-a29987ff2a77
    config: 
    permissions: 
      (empty array)
settings: 

Why can’t I see the schedules scopes?

Thanks


(Jim Anderson) #2

Hi @chetstone

Apologies for the difficulties. I will look into this more, but in the meantime:

You can try commenting out the permissions line in ./lib/config.js:

function createConfigInitializeSetting() {
  return {
    name: 'Weather bulb color',
    description: 'Bulb color by current temp',
    id: 'app',
    // This app needs permissions to read and write schedules
    // EDIT: Comment out the line below:
    // permissions:['r:schedules','w:schedules'],
    firstPageId: '1'
  }
}

I am going to look into this more and will follow up with more info and get the app updated as needed.

Thanks, sorry again!


(Chetstone) #3

Thanks for the quick reply, Jim. That got it working! Please let me know if you find out more about the underlying issue…

thanks again
Chester


(Jim Anderson) #4

Example app has been updated to fix this issue.

The issue was that in an effort to simplify things for developers and end-users, the requirement to have specific OAuth scopes for schedules is being removed. App schedules can be thought of as a platform feature, not specific permissions that a user should be aware of and authorize.

So, the r:schedules and w:schedules were removed from the workspace, but the example wasn’t updated at same time. So, when going through install flow, the error was because the permissions requested in the app’s config included permissions not in the app’s OAuth client scopes (the scopes selected in the workspace).

I’m working with the documentation team to get the docs updated as well to reflect this. Thanks for your patience and trying out the fix, super appreciated!!