REST Endpoint and dynamicPage


(Eran) #1

Hey all,

Has anyone had any luck adding a dynamic page to the preferences of a REST Endpoint app? I’m trying to add selective access to Hello, Home phrases similarly to the method used here: Can someone modify the big switch app to call Hello Home Phrases? it works inside the IDE but when I hit the endpoint with my browser, the page stops right after the drop down for selecting a location.

Any clues?
Eran.


(Tim Slagle) #2

Not sure what this means. Can you give us more details? The endpoint should not have a “dropdown” once the page is loaded then the endpoint action is taken. Please give a step hu step of what you did.

Are you asking about the transition from page to page in the app setup?


(Eran) #3

Hey Tim,

Here’s a screenshot:

The drop down I mention is the one that says “home” and the single bullet point below is where the list of devices (switches, locks and phrases in this case) should be.

Here’s the relevant code:

definition(
name: "REST Endpoint test",
namespace: "",
author: "Eran Globen",
description: "test dynamically loading Hello, Home phrases for REST app.",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
oauth: true)

preferences {
    page(name: "selectPhrases")
}



// phrases

// seems to not work because can't load dynmic page during oauth config.
def selectPhrases() {
	log.debug "loadings preferences..."
    dynamicPage(name: "selectPhrases", title: "Configure", uninstall: true) {	
        section("Allow Endpoint to Control These Things...") {
            input "switches", "capability.switch", title: "Which Switches?", multiple: true
            input "locks", "capability.lock", title: "Which Locks?", multiple: true
            log.debug location

			def phrases = location?.helloHome?.getPhrases()*.label
            if (phrases) {
                phrases.sort()
                log.debug phrases
                input "phrases", "enum", title: "Which phrases?", multiple: true, options: phrases
            }
		}
	}
}

(Tim Slagle) #4

Did you hit authorize to get the links to switches?

Also, you created a virtual switch to control the app right?


(Eran) #5

I don’t want to hit authorize yet because I haven’t selected which devices to control. And I’m not sure what this has to do with a virtual switch. The app will be controlled by whatever external client sends in HTTP requests.


(Tim Slagle) #6

Looks like an email/chat with Support is the next step.


(Matt Nohr) #7

Unfortunately, this is not possible right now. However, we are getting there. In the next week or so, we’ll have support for static pages being flagged as the one OAuth page to be used to get all the preferences to use during the OAuth flow. There is also worked plan to support this specific case of having dynamic pages used for OAuth.

Sorry this doesn’t help you now, but we are working on it!


(Eran) #8

Thanks, Matt! I’ll just leave it as is for now.


(Brandon) #9

Are there any updates on this issue?

I believe that I am having a similar issue when using the “Smart Alarm” app and going through the Oauth process. The “Smart Alarm” app uses dynamic pages.


(Geko) #10

Any update on this ?


(Matt Nohr) #11

@geko and @lacbra Good question. I think it got delayed but let me check on it to make sure.


(Matt Nohr) #12

This is now available. You can see it in the “Logitech Harmony Connect” SmartApp as an example. Basically it will work like this:

preferences(oauthPage: "deviceAuthorization") {
    page(name: "connect" ...
    page(name: "deviceAuthorization" ....

Where the oauthPage option is set in the preferences block.