Hi guys. I;m trying to do the same thing, but I donât see where the Endpoint IDs are obtained; that is, the specific device IDs.
I get to the point of calling:
https://graph.api.smartthings.com/api/smartapps/endpoints
And I receive the INSTALLATION_ID in the URL in the JSON:
[
{
âoauthClientâ:
{
âclientIdâ:âCLIENT_IDâ,
âauthorizedGrantTypesâ:âauthorization_codeâ
},
âurlâ:â/api/smartapps/installations/INSTALLATION_IDâ
}
]
So all good there.But in the walk-through, this is step 9:
PUT /api/smartapps/installations/INSTALLATION_ID/switches/8a818a9b39c0de7f0139c0dff1290073
Where is that GUID at the end obtained? Thatâs a specific switch ID, and I am not seeing that in any of my responses.
EDIT
I thought as much, I needed to include a listSwitches() routine. But none of the examples I found had any code for this, and as I am new to groovy and ST, I had no idea where to start.
Eventually I found SmartThings API Endpoint Example ¡ GitHub
And I included this code:
def listSwitches() {
switches.collect{device(it,"switch")}
}
private show(devices, type) {
def device = devices.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
}
else {
def attributeName = type == "motionSensor" ? "motion" : type
def s = device.currentState(attributeName)
[id: device.id, label: device.displayName, value: s?.value, unitTime: s?.date?.time, type: type]
}
}
private device(it, type) {
it ? [id: it.id, label: it.label, type: type] : null
}
Which returns a JSON object with all the switch GUIDs you could hope for.
Thank you!