Troubleshooting SmartThings Device Handler for SwitchLevel

I’m currently working on creating a custom device handler for SmartThings to control switchLevel devices via a RESTful API. However, I’m encountering an issue where the devices aren’t being recognized, resulting in the error message: ‘Smartthings not found devices type.’

Here’s the code I’m working with:

javascript
input “switchlevels”, type: “capability.switchLevel”, title: “Which Switchlevels?”, multiple: true, required: true

path(“/switchlevels”) {
action: [GET: “listSwitchlevels”]
}

path(“/switchlevels/:id”) {
action: [GET: “showSwitchlevel”]
}

path(“/switchlevels/:id/:lightLevel”) {
action: [GET: “updateSwitchlevel”]
}

function listSwitchlevels() {
log.debug " List listSwitchlevels params: ${params}"
switchlevels.collect{device(it,“switchLevel”)}
}

function showSwitchlevel() {
show(switchlevels, “switchLevel”)
}

void updateSwitchlevel() {
setLevelSwich(switchlevels)
}

I’ve verified that I have a compatible device—a GE Z-Wave Dimmer Switch—and it’s correctly paired with my SmartThings hub. Despite this, the devices aren’t being detected by the handler.

I suspect the issue might be related to how the devices are being initialized or how the API endpoints are structured. I’m particularly unsure about the device(it, "switchLevel") call in the listSwitchlevels function. Could this be causing the devices not to register properly?

Additionally, I’m wondering if there’s a specific way to handle multiple devices or if there’s an error in how the endpoints are defined. Any guidance or suggestions would be greatly appreciated to help resolve this issue.