Custom REST SmartApp Endpoint


#1

So you will have to excuse me as I am still pretty new at all this but I am struggling to be able to pull the temperature from a temperature sensor via REST SmartApp Endpoint. I followed @megapixel great tutorial here:

I can get my temperature sensors names, ids…all top level info, to show up but I can’t get the temperature. I think it has something to do with this code in the in the Endpoint App itself :

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]
	}
}

Any help would be great.


#2

For anyone else trying to get this figured out…It is pretty simple(doh!), just had to change the last line to:

[id: device.id, label: device.displayName, value: s?.value, unitTime: s?.date?.time, device.currentValue('temperature'), type: type]