Disable device from groovy?

Is there a way to disable a device from an App (groovy)?

I found this in the hidden feature post but can't get it to work... Not in groovy and not by putting it into the url bar (with a real ID and just true or false)

http://hubitat.local:8080/device/disable?id={ID}&disable={true|false}

or app...

http://10.0.0.186/installedapp/disable?id=4936&disable=true

Thanks

This is what I've tried so far... either option even close?

def disableDeviceHandler() {
    if(security) getCookie()
    disableMDevices.each { dmd ->
        dmdID = dmd.id
        log.debug "dmdID: ${dmdID}"

        def httpRequest = [
            method:		"GET",
            path: 		"/device/disable?id=${dmdID}&disable=true",
            headers:	[
                HOST:		"http://127.0.0.1:8080",
                Accept: 	"*/*",
            ]
        ]
        def hubAction = new hubitat.device.HubAction(httpRequest)
        sendHubCommand(hubAction)
    }
}
def disableDeviceHandler2() {
    if(security) getCookie()
    disableMDevices.each { dmd ->
        httpPost(
            [
                uri: "http://127.0.0.1:8080",
                path: "/device/disable?id=${dmdID}&disable=true",
                headers:[
                    "Cookie": cookie
                ]
            ]
        ) { resp ->	}
    }
}

Is that command even still active?

@gopher.ny , @thebearmay

I don’t think that one works anymore, but don’t remember the replacement.

1 Like

The endpoint is there and in use by UI. You'd want to post id and disable parameters as POST body instead of query string. That said, I'm not endorsing or encouraging its use...

1 Like

Thank you!