Android 2.4.0 - Release Notes

And once again ST does it’s magic and broken dynamic pages, this is probably the third time they’ve broken and fixed it and broken it again. I wonder why it’s so HARD to keep a set of test scripts to run before making a release.

This was working FINE in the 2.4.0 BETA release so obviously something broke between the BETA and the final release.

I have even posted this code to replicate the issue earlier for a previous release which was eventually FIXED by ST and it’s broken again, beyond frustrated right now!!

When opening a dynamic page HREF it passes the wrong data to the page, if you have 5 inputs, it passes the 5th input to the 1st href page. See the code below to replicate

definition(
    name: "Test HREF App",
    namespace: "smartthings",
    author: "SmartThings",
    description: "Test HREF Pages",
    category: "SmartThings Labs",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/App-LightUpMyWorld.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/App-LightUpMyWorld@2x.png"
)

preferences {
    page(name: "main")
    page(name: "testPage")
}


def main() {
    dynamicPage(name: "main", title: "HREF Test", uninstall: true, install: true) {
        for (int i = 1; i <= 5; i++) {
            def priorName = settings."userNames${i}" 
            section("User #${i}") { 
                if (priorName) {
                    input name: "userNames${i}", description: "${priorName}", title: "Name", defaultValue: priorName, type: "text", multiple: false, required: false, submitOnChange: true
                } else {
                    input name: "userNames${i}", description: "Tap to set", title: "Name", type: "text", multiple: false, required: false, submitOnChange: true
                }

                def hrefParams = [
                    user: i as String, 
                    passed: true 
                ]
                log.trace "$i Params: $hrefParams"
                href(name: "testPage", params: hrefParams, title: "Click here to define actions for ${settings."userNames${i}"}", page: "testPage", description: "", required: false)
            }
        }
        
        section("Mode Change Open Door/Window/Switch Notification") {
            def modes = location.modes
            for (mode in modes) {
                // Unlock actions for each mode
                def hrefParams1 = [
                    user: mode as String, 
                    passed: true 
                ]
                href(name: "modeDoorMonitor", params: hrefParams1, title: "When switching to mode ${mode}", page: "testPage", description: "", required: false)
            }
        }
    }
}

def testPage(params) {
    //  params is broken, after doing a submitOnChange on this page, params is lost. So as a work around when this page is called with params save it to state and if the page is called with no params we know it's the bug and use the last state instead
    if (params.passed) {
        atomicState.params = params // We got something, so save it otherwise it's a page refresh for submitOnChange
    }

    def user = atomicState.params?.user ?: ""
    def name = user ? settings."userNames${user}" : ""

    log.trace "Actions Page, user:$user, name:$name, passed params: $params, saved params:$atomicState.params"

    dynamicPage(name:"testPage", title: "Setup actions for each door" + (user ? " for user $name." : ""), uninstall: false, install: false) {
        section {
            input "userOverrideUnlockActions${user}", "bool", title: "Define specific actions for $name", required: true,  submitOnChange: true
        }
    }
}

def initialize() {
}

def updated() {
}

@kleneau

4 Likes